cancel
Showing results for 
Search instead for 
Did you mean: 

How to create checkbox group and table dynamically?

Former Member
0 Kudos

HI All

How to create checkbox group and table dynamically?

Regards

Ravi

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Why can't you create them at design time?

Armin

Former Member
0 Kudos

Hi Armin,

We are trying to do in run time.

we can create at design time. we know it.

but we are trying differently

Former Member
0 Kudos

I suggest to use programmatic creation of UI elements only when really needed.

To answer your question (for the table, check box group is analog), you have to do several things:

- provide context node(s) and attributes(s) to which you bind the properties of the table. This can be created at design time (easy) or at runtime (not so easy)

- fill the context node with elements e.g. using a supply function

- in wdDoModifyView(), check some flag that determines when to create the table e.g. the "firstTime" flag

- use the UI element API methods like IWDView.createElement(...) to create the table instance and add it to some existing container. Bind the table's data source property to some context node, add a cell editor, bind its properties to some context attributes under the data source node

- if needed assign action to the events of the cell editor(s)

Armin

gill367
Active Contributor
0 Kudos

Hello Ravi

following is the code you should write in the wddomodify method to create the check box group and table dynamically.

IWDTray mytray = (IWDTray)view.getElement("Tray");
   IWDTable table = (IWDTable)view.createElement(IWDTable.class,"Table");
   table.bindDataSource(wdContext.nodeSourceNode().getNodeInfo());
   mytray.addChild(table);
   IWDCheckBoxGroup cbg = (IWDCheckBoxGroup)view.createElement(IWDCheckBoxGroup.class,"ChkBxGrp");
   cbg.bindTexts(wdContext.getNodeInfo().getAttribute("ddk"));
   mytray.addChild(cbg);

Thanks

Sarbjeet Singh

Former Member
0 Kudos

Hi,

I followed the same procedure but table is not created dynamically. It is displaying blank page.

Cheers

Ravi

Former Member
0 Kudos

Hi

I tried the same code. Its working.

Make sure

1. You created the Tray UI element with ID as "Tray'.(This UI element should be in visible mode)

2. You created the SourceNode in your context

3. You created the attribute of boolean type "ddk" in context.

4. Write this below code in if (firstTime) {{} of wdDoModifyView() method.

It works!!...And if you getting any error just post that error.

IWDTray mytray = (IWDTray)view.getElement("Tray");

IWDTable table = (IWDTable)view.createElement(IWDTable.class,"Table");

table.bindDataSource(wdContext.nodeSourceNode().getNodeInfo());

mytray.addChild(table);

IWDCheckBoxGroup cbg = (IWDCheckBoxGroup)view.createElement(IWDCheckBoxGroup.class,"ChkBxGrp");

cbg.bindTexts(wdContext.getNodeInfo().getAttribute("ddk"));

mytray.addChild(cbg);

Regards,

Charan

Former Member
0 Kudos

Hi charan,

we created the table dynamically and we can able to add columns to that table, but how to set the header for columns.

we tried this code, but we got compile time error at '''setHeader(IWDCaption "NAME")..'''

IWDTableColumn name = (IWDTableColumn)view.createElement(IWDTableColumn.class,"name");

name.setHeader(IWDCaption "NAME");

table.addColumn(name);

Thanks & Regards,

Sreelakshmi.

Former Member
0 Kudos

Please read the Javadoc and try to understand it. Why should the line


name.setHeader(IWDCaption "NAME");

compile?

Armin

Former Member
0 Kudos

Hi Armin,

How can we add columns to a table dynamically?

Former Member
0 Kudos

IWDTable table = ...;
IWDTableColumn column = (IWDTableColumn) view.createElement(IWDTableColumn.class, "column_id");
table.addGroupedColumn(column);

Armin

Former Member
0 Kudos

Hi,

I tried with ur code.

From this code i am able to create only columns, but i want to create column header for each column.

Can u please provide me code.

Thanks!

Former Member
Former Member
0 Kudos

hi

check this links for creating tables dnamically

and for checkboxgroup

IWDTransparentContainer rootContainer =

(IWDTransparentContainer)view.getElement("RootUIElementContainer");

IWDCheckBox check = (IWDCheckBox)view.createElement(IWDCheckBox.class,"Check"+k);

//Here "check"+k k represents a unique value every time u create so that u wont get a duplicate instance

check.setChecked(false);

rootContainer.addChild(check);

or

birojpatro
Contributor
0 Kudos

Hi Ravi,

Have a look at the document on SDN [Link|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/74cda090-0201-0010-6b91-f85b2489f765]

Hope this helps.

Good Luck!!!

Biroj Patro.