2

I am using the example :

http://www.smartclient.com/smartgwt/showcase/#tree_interaction_drag_nodes

but changed the datasource to XML file and now its not working.

The XML used is :

<RootNode>
<ChildNode>
    <ChildID>2</ChildID>
    <Name>ChildNode1</Name>
    <ReportsTo>1</ReportsTo>
</ChildNode>
<ChildNode>
    <ChildID>3</ChildID>
    <Name>ChildNode1.1</Name>
    <ReportsTo>2</ReportsTo>
</ChildNode>
<ChildNode>
    <ChildID>4</ChildID>
    <Name>ChildNode2</Name>
    <ReportsTo>1</ReportsTo>
</ChildNode>
<ChildNode>
    <ChildID>5</ChildID>
    <Name>ChildNode2.1</Name>
    <ReportsTo>4</ReportsTo>
</ChildNode>
<ChildNode>
    <ChildID>6</ChildID>
    <Name>ChildNode2.1.1</Name>
    <ReportsTo>5</ReportsTo>
</ChildNode>
</RootNode>

whereas for grid1 and grid2 i am changing the datasources to the xml file as follows :
Instead of :

grid1.setData(grid1Tree);  
grid1.getData().openAll(); 

I am using :

    grid1.setAutoFetchData(true);  
    grid1.setDataSource(EmployeeXmlDS.getInstance());    
    grid1.draw();

And similarly for grid2. And here is the EmployeeXmlDS implementation :

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;


public class EmployeeXmlDS extends DataSource {

    private static EmployeeXmlDS instance = null;

    public static EmployeeXmlDS getInstance() {
        if (instance == null) {
            instance = new EmployeeXmlDS("employeesDS");
        }
        return instance;
    }

    public EmployeeXmlDS(String id) {

        setID(id);
        setTitleField("Name");
        setRecordXPath("/RootNode/ChildNode");
        DataSourceTextField nameField = new DataSourceTextField("Name", "Name", 128);
        DataSourceIntegerField childIdField = new DataSourceIntegerField("ChildID", "Child ID");
        childIdField.setPrimaryKey(true);
        childIdField.setRequired(true);
        DataSourceIntegerField reportsToField = new DataSourceIntegerField("ReportsTo", "Parent");
        reportsToField.setRequired(true);
        reportsToField.setForeignKey(id + ".ChildID");
        reportsToField.setRootValue("1");
        setFields(nameField,childIdField,reportsToField);
        setDataURL("ds/test_data/tree2.xml");
        setClientOnly(true);
    }
}

Please help.

Sagar Tandel
  • 299
  • 1
  • 3
  • 10
  • What is the problem that you have? The tree is not loading, the dragging not working? Provide more info and some code snippet to receive more help ... – gpapaz Feb 28 '12 at 20:53
  • The drag drop is not working...Also check the code inserted above.. – Sagar Tandel Feb 29 '12 at 06:00
  • I assume you grid1 is still of PartsTreeGrid type and you haven't changed anything in that code, compared to the code I see in the smartGWT's example, correct? – gpapaz Feb 29 '12 at 10:31
  • Yes..both grid1 and grid2 are PartsTreeGrid..will it matter?? – Sagar Tandel Mar 01 '12 at 09:21
  • Just wanted to make sure you aren't missing any needed configuration options. So compared to the example, the only changes are the lines in your question, right? – gpapaz Mar 01 '12 at 09:31
  • Yes...thats all you will need to do to recreate the scenario.. – Sagar Tandel Mar 01 '12 at 09:44
  • Can you post your EmployeeXmlDS implementation? It looks like there might be some mismatch between your parsing and your tree definitions. – gpapaz Mar 01 '12 at 13:27
  • I have posted the EmployeeXmlDS implementation above...Please check.. – Sagar Tandel Mar 01 '12 at 13:50
  • Did it work...any lead or idea why its not working..please reply.. – Sagar Tandel Mar 03 '12 at 11:27
  • 1
    No it didn't. Maybe you want to look into this http://www.smartclient.com/smartgwt/showcase/#grid_db_dragging_featured_category for another way to possibly achieve what you are after. – gpapaz Mar 03 '12 at 15:44
  • Hey please help me this task...I am just not able to achieve it..even the link u gave was helpful but it works only for COPY operation not MOVE...Please help.. – Sagar Tandel Mar 21 '12 at 15:20
  • Open a chat room and lets see if we can make it work ... – gpapaz Mar 21 '12 at 15:26
  • return to the previous chatroom we used – Sagar Tandel Mar 21 '12 at 15:34

0 Answers0