on 05-13-2009 9:37 AM
HI All
How to create checkbox group and table dynamically?
Regards
Ravi
Why can't you create them at design time?
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
Please read the Javadoc!
Armin
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);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
77 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.