I am using multi column tree. can we add a new row to the Tree ? If so please give me some pointers to add a new row. I appreciate your help. Thanks in advance.
TreeGrid.addData() doesn’t work for you?
Thanks for the quick reply.
I can add a record to the tree, but I need to get the input values from the user. Do we need to create the window to get the user input or is there any method available similar to I to implement like the ListGrid.startNew().
To do that, use addData(), then when that completes (use the callback to find out), startEditing() at that row.
Any sample implementation or example ? Thanks in advance for the help.
Not of this specific case but it should be fairly straightforward. Have you attempted to implement the suggestion using the Javadocs? If not, please do so and if you’re having trouble post your code.
Sanjiv
Please post the java doc samples link.
Are you having trouble locating these methods in the javadoc?
I found three addData() methods. I tried using public void addData(Record record, DSCallback callback).
Here what should i set for Record value? I need to create the record based on the user input, for this i am prompting startEditNew() method. This method returns void and I don’t know how to get the user entered values in the startEditNew() record.
Please help me to resolve this. I appreciate your help.
Use TreeGrid.addData(), use the signature that has a Callback, provide a callback that calls startEditing() (not startEditingNew) when the addData completes.
This is my code. The addData call back method never called back. Please help me to fix this.
addBtn.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
int treeGridSize=0;
ListGridRecord[] records = treeGrid.getRecords();
if(records != null)
treeGridSize= records.length;
ListGridRecord newRecord = new ListGridRecord();
newRecord.setAttribute("nodeName", "attribute1");
newRecord.setAttribute("nodeID", "attribute1");
newRecord.setAttribute("parentNodeID", "root");
newRecord.setAttribute("nodeType", "string");
newRecord.setAttribute("minOccurs", "1");
newRecord.setAttribute("maxOccurs", "1");
newRecord.setAttribute("canEditRow", true);
infoModelTree.addData(newRecord, new DSCallback(){
public void execute(DSResponse response, Object rawData,
DSRequest request) {
Log.info("Inside start Editing the record");
infoModelTree.startEditing();
//I need to add the new record at the end of the tree grid
//and make editable and set focus
}
});
I tried couple of options and at the end I am successful. The below code can able to add a new record with default values and prompt the user to edit.
TreeNode newTreeNode = new InfoModelTreeNode("", ""...);
TreeNode rootNode = tree.getRoot();
tree.add(newTreeNode, rootNode);
int lastRowIndex = infoModelTree.getLength()-1;
treeGrid.startEditing(lastRowIndex,0,false );