Dynamic add column to datatable
Hi ,
How can I add columns to datatable dynamically ? I don't know how many columns will be selected.
Actually I don't know how to do it in the jsp file. There is columns tag in it. Is there any tag like 'for' ?
Thanks in advance.
Wilson
thanks for that but still cannot figure out what is wrong with my code (I'm really getting crazy !). I can see the titles of the columns but I cannot see any data. Any ideas ?
<h:dataTable styleClass="dataTable" id="tablecsv"
binding="#{mainPage.dataTable}" rendered="#{mainPage.completed}"
value="#{mainPage.resultsModel}" var="varresultsModel" />
public UIData getDataTable()
FacesContext context = FacesContext.getCurrentInstance();
String[] cols = getTheTable();
List children = dataTable.getChildren();
children.clear();
dataTable.setVar("vartableRow");
for (int i = 0; i < cols.length; i++)
UIColumn col = new UIColumn();
col.setId("column" + i); //?
UIOutput out = new UIOutput(); //?
out.setId(cols[i] + i); //?
/* children.add(col);
HtmlOutputText header = new HtmlOutputText();
String label = "" + cols;
header.setValue(label);
col.setHeader(header);
HtmlOutputText data = new HtmlOutputText();
col.getChildren().add(data);
data.setValueBinding("value", context.getApplication().createValueBinding("#{" + (i +1) + "}"));
HtmlOutputText header = new HtmlOutputText();
String label = "" + cols[i];
header.setValue(label);
col.setHeader(header);
ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{result." + cols[i] + "}");
out.setValueBinding("value", vb);
col.getChildren().add(out);
dataTable.getChildren().add(col);
this.completed = true;
return this.dataTable;
public ArrayList getResultsModel()
this.resultsModel = new ArrayList();
for (int n = 0; n < getTheTable().size() - 1; n++)
this.resultsModel.add(new Integer(n));
return this.resultsModel;
Similar Messages
-
Hi folks,
Plz tell me if u know how can i add column dynamically
in oracle content management SDK webstarterapp.I am stucked here for quite sometimes.plz tell me ASAP.
Regards
PrasenjitTake a look at:
http://download-east.oracle.com/docs/html/B12187_02/toc.htm
You should use OMBALTER TABLE command.
Regards,
Marcos -
Dynamic add column in Bex report
Hi all,
we have input parameter is month wise. For example if i have input 12.2011 - 03.2012
Output:
12.2011--01.2012--02.2012-----04.2012
50kg -
70--90--
54
Like above dynamically have to change column based on month input parameter. Please guide me how to design bex query.
Thanks
Saravananhi,
restrict calmonth with variable type manual input, and put this calmonth in columns on top of amount or quantity. It will give you your desired output.
hope this helps,
regards,
ray
Edited by: ray100 on Mar 9, 2012 2:54 PM -
Hi,
I want to add column to dataTable in Studio Creator. How can I do that ? Any idea ?
Thanks
WilsonIn your bean code add code something like below
private UIColumn mycolumn = new UIColumn();
public UIColumn getMyColumn() {
return mycolumn ;
public void setMyColumn(UIColumn uic) {
this.mycolumn = uic;
}and in your jsf page you can do something like below
<h:column binding="#{YourBean.mycolumn }" id="column1">
<h:outputText value="My Value"/>
<f:facet name="header">
<h:outputText value="My Header"/>
</f:facet>
</h:column>regards
Sudhakar -
How to create dynamic DataTable with dynamic header/column in JSF?
Hello everyone,
I am having problem of programmatically create multiple DataTables which have different number of column? In my JSF page, I should implement a navigation table and a data table. The navigation table displays the links of all tables in the database so that the data table will load the data when the user click any link in navigation table. I have gone through [BalusC's post|http://balusc.blogspot.com/2006/06/using-datatables.html#PopulateDynamicDatatable] and I found that the section "populate dynamic datatable" does show me some hints. In his code,
// Iterate over columns.
for (int i = 0; i < dynamicList.get(0).size(); i++) {
// Create <h:column>.
HtmlColumn column = new HtmlColumn();
dynamicDataTable.getChildren().add(column);
// Create <h:outputText value="dynamicHeaders"> for <f:facet name="header"> of column.
HtmlOutputText header = new HtmlOutputText();
header.setValue(dynamicHeaders[i]);
column.setHeader(header);
// Create <h:outputText value="#{dynamicItem[" + i + "]}"> for the body of column.
HtmlOutputText output = new HtmlOutputText();
output.setValueExpression("value",
createValueExpression("#{dynamicItem[" + i + "]}", String.class));
column.getChildren().add(output);
public HtmlPanelGroup getDynamicDataTableGroup() {
// This will be called once in the first RESTORE VIEW phase.
if (dynamicDataTableGroup == null) {
loadDynamicList(); // Preload dynamic list.
populateDynamicDataTable(); // Populate editable datatable.
return dynamicDataTableGroup;
I suppose the Getter method is only called once when the JSF page is loaded for the first time. By calling this Getter, columns are dynamically added to the table. However in my particular case, the dynamic list is not known until the user choose to view a table. That means I can not call loadDynamicList() in the Getter method. Subsequently, I can not execute the for loop in method "populateDynamicDataTable()".
So, how can I implement a real dynamic datatable with dynamic columns, or in other words, a dynamic table that can load data from different data tables (different number of columns) in the database at run-time?
Many thanks for any help in advance.flyeminent wrote:
However in my particular case, the dynamic list is not known until the user choose to view a table. Then move the call from the getter to the bean's action method. -
Dynamic columns in datatable...
Hi guys,
i've a question about datatable.
I have to use datatable for inserting data into db.
My question is:
I'm developed a datatable with 5 columns and various rows,i've create an actionlistener and when i click it each row is successfully inserted.
Now i want adding some columns to datatable depending by a number inserted by user.
That is:
the user inserts 3(for example) and the user sees in another page
the datatable with the 5 fixed columns and others 3 columns...
Clicking the actionListener i want the 5 columns values were inserted in a table(and it's easy) and the others variable column's number were inserted as different row in another table...
excuse me for my english....i try an example....
This can be one row
giuseppe napoli milano italia europa ---variable(age address sex)----i want giuseppe napoli milano italia europa is inserted as a row in user table and age,address,sex are inserted as different rows into details table....
i want knowing how ciclying among dynamic different columns values and inserting each value as a different row....
thanks very much,please help me with code or ideas...thanks...
but my problem is this:
i've create a populate method that has to add dynamic column,i've supposed a fixed value,3, to my existing datatable.
public HtmlDataTable populateMyDataTable() throws Exception{
getBiosampleDataTable();
for (int i=0;i<2;i++){
//UIOutput header = new UIOutput();
//header.setValue(headers);
// Set output.
UIInput output = new UIInput();
ValueBinding biosampleItem =
FacesContext
.getCurrentInstance()
.getApplication()
.createValueBinding("#{biosampleItem[" + i + "]}");
output.setValueBinding("value", biosampleItem);
// Set column.
UIColumn column = new UIColumn();
//column.setHeader(header);
column.getChildren().add(output);
// Add column.
biosampleDataTable.getChildren().add(column);
setBiosampleDataTable(biosampleDataTable);
return biosampleDataTable;
i've
public HtmlDataTable getBiosampleDataTable() throws Exception {
loadBiosamples();
return populateMyDataTable();
}and
public void loadBiosamples() throws Exception {
if (load==0){
for (int i = 0; i < nrows; i++) {
Biosample biosample = new Biosample();
biosamples.add(biosample);
setBiosamples(biosamples);
load=1;
else
setBiosamples(biosamples);
where is my error?
I'vejavax.faces.el.EvaluationException: javax.faces.el.EvaluationException: Exception getting value of property biosampleDataTable of base of type : giu.BiosamplesTableand i'm not sure about my code...can you help me? -
How to add column dynamically based on user input in oracle?
**how to add column dynamically based on user input in oracle?**
I am generating monthly report based on from_date to to_date below is my requirement sample table
EMPLOYEE_CODE| Name | CL_TAKEN_DATE | CL_BALANCE | 01-OCT-12 | 02-OCT-12 | 03-OCT-12
100001.............John...........02-OCT-12...............6
100002.............chris...........01-OCT-12...............4
Based on user input, that is, if user need the report from 01-OCT-12 TO 03-OCT-12, i need to add that dates as column in my table, like 01-OCT-12 | 02-OCT-12 | 03-OCT-12....
below is my code
create or replace
procedure MONTHLY_LVE_NEW_REPORT_demo
L_BUSINESS_UNIT IN SSHRMS_LEAVE_REQUEST_TRN.BUSINESS_UNIT%TYPE,
--L_LEAVE_TYPE_CODE IN SSHRMS_LEAVE_REQUEST_TRN.LEAVE_TYPE_CODE%TYPE,
L_DEPARTMENT_CODE IN VARCHAR2,
--L_MONTH IN SSHRMS_LEAVE_REQUEST_TRN.LVE_FROM_DATE%TYPE,
L_FROM_DATE IN SSHRMS_LEAVE_REQUEST_TRN.LVE_FROM_DATE%TYPE,
L_TO_DATE in SSHRMS_LEAVE_REQUEST_TRN.LVE_TO_DATE%type,
MONTHRPT_CURSOR OUT SYS_REFCURSOR
AS
O_MONTHRPT_CURSOR_RPT clob;
v_return_msg clob;
BEGIN
IF (L_BUSINESS_UNIT IS NOT NULL
AND L_FROM_DATE IS NOT NULL
and L_TO_DATE is not null
-- AND L_DEPARTMENT_CODE IS NOT NULL
THEN
OPEN MONTHRPT_CURSOR FOR
select EMPLOYEE_CODE, EMPLOYEE_NAME AS NAME, DEPARTMENT_CODE AS DEPARTMENT,DEPARTMENT_DESC, CREATED_DATE,
NVL(WM_CONCAT(CL_RANGE),'') as CL_TAKEN_DATE,
case when NVL(SUM(CL2),0)<0 then 0 else (NVL(SUM(CL2),0)) end as CL_BALANCE,
from
SELECT DISTINCT a.employee_code,
a.EMPLOYEE_FIRST_NAME || ' ' || a.EMPLOYEE_LAST_NAME as EMPLOYEE_NAME,
a.DEPARTMENT_CODE,
a.DEPARTMENT_DESC,
B.LEAVE_TYPE_CODE,
B.LVE_UNITS_APPLIED,
B.CREATED_DATE as CREATED_DATE,
DECODE(b.leave_type_code,'CL',SSHRMS_LVE_BUSINESSDAY(L_BUSINESS_UNIT,to_char(b.lve_from_date,'mm/dd/yyyy'), to_char(b.lve_to_date,'mm/dd/yyyy'))) CL_RANGE,
DECODE(B.LEAVE_TYPE_CODE,'CL',B.LVE_UNITS_APPLIED)CL1,
b.status
from SSHRMS_EMPLOYEE_DATA a
join
SSHRMS_LEAVE_BALANCE C
on a.EMPLOYEE_CODE = C.EMPLOYEE_CODE
and C.STATUS = 'Y'
left join
SSHRMS_LEAVE_REQUEST_TRN B
on
B.EMPLOYEE_CODE=C.EMPLOYEE_CODE
and c.EMPLOYEE_CODE = b.EMPLOYEE_CODE
and B.LEAVE_TYPE_CODE = C.LEAVE_TYPE_CODE
and B.STATUS in ('A','P','C')
and (B.LVE_FROM_DATE >= TO_DATE(L_FROM_DATE, 'DD/MON/RRRR')
and B.LVE_TO_DATE <= TO_DATE(L_TO_DATE, 'DD/MON/RRRR'))
join
SSHRMS_LEAVE_REQUEST_TRN D
on a.EMPLOYEE_CODE = D.EMPLOYEE_CODE
and D.LEAVE_TYPE_CODE in ('CL')
AND D.LEAVE_TYPE_CODE IS NOT NULL
group by EMPLOYEE_CODE, EMPLOYEE_NAME, DEPARTMENT_CODE, DEPARTMENT_DESC, CREATED_DATE
else
v_return_msg:='Field should not be empty';
end if;
END;
my code actual output
EMPLOYEE_CODE| Name | CL_TAKEN_DATE | CL_BALANCE
100001....................John............02-OCT-12.................6
100001....................chris...........01-OCT-12.................4
how to add column dynamically based on from_date to to_date?
Thanks and Regards,
Chris Jerome.You cannot add columns dynamically. But you can define a maximum number of numbers and then hide unused columns in your form useing SET_ITEM_PROPERTY(..,VISIBLE, PROPERTY_FALSE);
-
Hello All,,
There used to be an option in Hyperion planning 11.1.1.3 to Dynamic add rows in data form. I don't see this option in planning 11.1.2.1 ?
Could you please suggest how we can grant right users to add dynamic add rows and columns in data forms? or it is possible in 11.1.2.1 ?
out user want to have a feature of adding row in data forms (planning forms)
Thank you
Edited by: 842804 on Aug 17, 2011 12:49 PMDo you mean 11.1.2, if so then adhoc web forms really take over from adding rows as they add much more functionality.
Cheers
John
http://john-goodwin.blogspot.com/ -
How to delete or add columns in a DataTable.
Hi,
I need to delete/add columns for a DataTable programaticaly... Can anyone help me in this ??. In source code I added a datatable and lets take 3 columsn I added. While running application, I need to delete and add columns whenever I want.
Please help me....can you give a sample code for this... I really want
this code...
just to re-confirm you, I want to add or delete
columns not rows...I don't have sample code, why don't you give it a try? -
How to add column in Dynamic VO
Hello All,
We are on 11.5.10 and
i am trying to add a column toProduct - Supplier Items - click Orders page
when i click about this page it is showing this
POS_SUPPLIER_INQUIRIES177_POS_PO_LINES_D2177_177POS_PO_LINES_DDynamicVO
This has Dynamci VO.
How do i add column to this view.
It seems that this view is based on AK Region POS_PO_LINES_D and this region is based on a view POS_PO_LINES_V.
Please help me in doing this.
Thanks,
Mehta.Check the page's controller code. That will point you to the base definition of the VO used in the dynamic view.
--Shiv -
How to add columns for existing table dynamically?
Hi,
I created table structure only. I want to add columns for this existing table. Columns are not fixed, according to the user choice i need to write code.
Plz give me reply asap.
Thanks
ShirishaHi Shirisha,
I think the following code snippet will help you.
int l_no_cols = 0;
//Get the number of columns in this variable, something like the following
//l_no_cols = wdContext().currentContextElement().get<Context_attribute_name>;
IWDTable l_tab;
IWDTransparentContainer l_tbl_cont = (IWDTransparentContainer)view.getElement("TableDataCont");//ID of Container
l_tab = (IWDTable)view.getElement("TableData");//ID of Table
l_tab.setVisible(WDVisibility.VISIBLE);
l_tab.bindDataSource(wdContext.nodeTable_Data().getNodeInfo());
for(int a = 1; a <=l_no_cols; a++)
//Creating the column
IWDTableColumn l_tab_col = (IWDTableColumn)view.createElement(IWDTableColumn.class,"COL"+a);
//Creating Caption for Column Header
IWDCaption l_tab_cap = (IWDCaption)view.createElement(IWDCaption.class,"Caption"+a);
l_tab_cap.setText("Col"+i);
l_tab_col.setHeader(l_tab_cap);
//Creating Table Cell Editor for column
IWDInputField l_tab_cell = (IWDInputField)view.createElement(IWDInputField.class,"CellEditor"+a);
//creating context node attribute for the column dynamically
wdContext.nodeTable_Data().getNodeInfo().addAttribute("Col"+i,"com.sap.dictionary.String");
l_tab_cell.bindValue(wdContext.nodeTable_Data().getNodeInfo().getAttribute("Col"+i));
l_tab_col.setTableCellEditor(l_tab_cell);
l_tab.addColumn(l_tab_col);
l_tbl_cont.addChild(l_tab);
Regards,
Alka -
Hello All,,
There used to be an option in Hyperion planning 11.1.1.3 to Dynamic add rows in data form. I dont see this option in planning 11.1.1.2 ?
Could you please suggest how we can grant right users to add dynamic add rows and columns? or it is possible in 11.1.1.2
Thank youHow about ad-hoc analysis? Have a read of this: http://download.oracle.com/docs/cd/E17236_01/epm.1112/hp_user/ch04s02s03.html
Cheers,
Mehmet -
How to add columns dynamically in a classical rep deending on a parameter
hi all,
i have a scenario where ii have to add columns in my report depending on a certain parameter.the report should dymnamically add the columns based on the parameter.Hello Diego
Revert your logic and remove or do not display columns if the corresponding parameter is missing or does not have the expected value(s).
Using ALV lists you would accomplish this using the following coding:
IF ( <parameter is missing or has not expected value> ).
ls_fcat-tech = 'X'.
MODIFY gt_fcat FROM ls_fcat
TRANSPORTING tech
WHERE ( fieldname = <column> ).
ENDIF.
The column for which this attribute is set in the fieldcatalog will appear neither in the ALV list nor in the layout.
Now for a classical report (WRITE report ?!) you should develop a similar logic. You have to encapsulate the displaying or writing for each column and make this dependent from the parameter, e.g.:
LOOP AT gt_data INTO ls_data.
IF ( <parameter is missing or has not expected value> ).
" do nothing -> skip this column
ELSE.
PERFORM write_column USING ...
ENDIF.
ENDLOOP.
Regards
Uwe -
Design problem with dynamically added row in datatable
Hello all,
I have a dataTable and have developped a method that dynamically adds rows to the dataTable. Each row is made up of two form controls. The problem I have now is that I don't know how to retrieve the values from the mutiple rows. Ideally I would need the values to be stored into a list.
Can anyone help?
Thanks in advance,
Julien.
Here is my code:
<h:dataTable var="line" binding="#{TradeClientsAndQuantitiesBean.clientsAndQuantities}" value="#{TradeClientsAndQuantitiesBean.listOfMiddleFormHelpers}">
<h:column>
<f:facet name="header">
<h:outputText value="S�lectionnez un client"/>
</f:facet>
<h:selectOneMenu value="#{TradeClientsAndQuantitiesHelperBean.selectedClientTemp}">
<f:selectItems value="#{TradeClientsAndQuantitiesHelperBean.concatenatedLabelMap}"/>
</h:selectOneMenu>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Renseignez une quantit�"/>
</f:facet>
<h:inputText value=""/>
</h:column>
</h:dataTable>The values will just be put in the same row object you added to TradeClientsAndQuantitiesBean.listOfMiddleFormHelpers.
It might be worth to read this article: http://balusc.xs4all.nl/srv/dev-jep-dat.html -
Values from columns of datatable...
Hi guys,
i'm working with my jsf application to create a datatable.
It works well,but now i've added a commandlink button to dynamically adding a new column(i use this datatable for input data,each row is an experiment).
It works fine,column is correctly added.
At the end of each row of my datatable i've a submit button to send values of the row into db.
My question is:
My datatable has 5 fixed fields and other dinamic fields that user can add with button. My 5 fixed values have to go into a table(and it works) and i want that dynamic values(that use has added) go into another table,each one as a different row.
Example
usa italy french england japan rome tokyo
i want usa italy french englan japan go into a table(as a row) and rome tokio goes into another table
rome
tokio(different rows).
How can i do it?
My problem is i'm not able to binding the dynamic input fields to bean....can you help me?
Here is my class
public class BiosamplesTable {
private List biosamples= new ArrayList();
private HtmlDataTable biosampleDataTable;
private int autokey2;
private Biosample biosampleItem;
private int nrows;
private DataModel mColumns;
private int load=0;
private String columnLabel;
public HtmlDataTable getBiosampleDataTable() {
return biosampleDataTable;
public void setBiosampleDataTable(HtmlDataTable biosampleDataTable) {
this.biosampleDataTable = biosampleDataTable;
public Biosample getBiosampleItem() {
return biosampleItem;
public void setBiosampleItem(Biosample biosampleItem) {
this.biosampleItem = biosampleItem;
public List getBiosamples() throws Exception {
loadBiosamples();
// Reload after every request.
return biosamples;
public void setBiosamples(List biosamples) {
this.biosamples = biosamples;
public void loadBiosamples() throws Exception {
if (load==0){
for (int i = 0; i < nrows; i++) {
Biosample biosample = new Biosample();
biosamples.add(biosample);
setBiosamples(biosamples);
load=1;
else
setBiosamples(biosamples);
public int getNrows() {
return nrows;
public void setNrows(int nrows) {
this.nrows = nrows;
public DataModel getColumnDataModel()
if (mColumns == null)
String[] result = new String[]{};//sono le colonne di partenza,in questo caso 1!!!
mColumns = new ListDataModel(new ArrayList(Arrays.asList(result)));
return mColumns;
public void addColumn(ActionEvent e)
if(columnLabel!=null);//metter l'if
List columns = (List) getColumnDataModel().getWrappedData();
columns.add(columnLabel);
public String getColumnLabel(){
return columnLabel;
public void setColumnLabel(String columnLabel){
this.columnLabel=columnLabel;
}and this is my jsp page
<t:dataTable
value="#{biosamplesTable.biosamples}"
var="biosampleItem"
binding="#{biosamplesTable.biosampleDataTable}" border="3" bgcolor="pink" >
<h:column >
<f:facet name="header">
<h:outputText value="Organism"/>
</f:facet>
<h:selectOneMenu value="#{biosampleItem.organism}">
<f:selectItems value="#{biosample.selectOrganism}"/>
</h:selectOneMenu>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Treatment Protocol" />
</f:facet>
<h:inputText value="#{biosampleItem.treatmentProtocol}" />
</h:column>
<h:column >
<f:facet name="header">
<h:outputText value="Extraction Method" />
</f:facet>
<h:inputText value="#{biosampleItem.extractionMethod}" />
</h:column>
<h:column >
<f:facet name="header">
<h:outputText value="Label"/>
</f:facet>
<h:inputText value="#{biosampleItem.label}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Hybridation" /></f:facet>
<h:inputText value="#{biosampleItem.hybridation}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Amplification" /></f:facet>
<h:inputText value="#{biosampleItem.amplification}" />
</h:column>
<t:columns value="#{biosamplesTable.columnDataModel}" var="column" >
<f:facet name="header">
<h:panelGroup>
<h:outputText value="#{column}" />
<h:commandLink actionListener="#{biosamplesTable.removeColumn}">
<h:outputText value="Elimina"/>
</h:commandLink>
</h:panelGroup>
</f:facet>
<h:inputText value="#{biosampleProperties.value}" />
</t:columns>
<h:column>
<f:facet name="header">
<h:outputText value="Actions" />
</f:facet>
<h:commandLink
value="Invia dati biosample" actionListener="#{biosamplesTable.editBiosample}" id="editBiosample">
</h:commandLink>
</h:column>
</t:dataTable> i want the values of each added column goes as different row into a biosampleProperties table....
Thanks..u can't achieve this with DataTable u need tu use JSTL ...exactly the
C-Tag
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
Maybe you are looking for
-
Is Nokia releasing a new firmware for the E72?
After the bugs introduced with the latest firmware (no company search, SMS and calls recepction,...), does anybody know if Nokia has plans to fix them in a new firmware release?
-
I can't get Adobe photoshop elements 12 to launch. Error 0xc000007b
Hello if someone could help me I would greatly appreciate it. I've recently installed Adobe Photoshop Elements 12. But I am yet to get the software to start, instead I get the following message: 'The application was unable to start correctly (0xc0000
-
How do I download in Safari and read pdf documents on ipad?
Have brand new iPad and want to download a pdf document using Safari as browser and read on the iPad. I have Adobe Reader app and Files app. iCloud is enabled. Reading List only shows download page. I can download this document quickly on my Lapt
-
My PowerBook G3 gives me a gray screen with a flashing ?. It was returned to me from an eBay sale in this condition. I have tried the reset, etc., etc. Nothing is working! Help!
-
What is the best way to do Unique Key validation?
Hi All, I'll have to provide a user friendly message when users create a record using an existed key (Most of the keys are combination key). How to do it in a generic way? Thank you in advance.