Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Tree getPath returns path of ids, not names

    I load a treegrid from a RestDataSource shown below. If I request a getPath(node) I get a path like /1/4/7 rather than /lib/foo/bar. If I try to get the NameProperty, it display "$399". If I try to set the name property I get a null exception. Since a Datasource creates the tree, how do I set it up to display names in paths?

    Code:
    private ProjectDataSource getData(Map<String,String> args) {
    String context = args.get("context");
    assert(context != null);
    ProjectDataSource datasource = new ProjectDataSource(context,"ThinkSpace","library.xq");
    datasource.setRecordXPath("/response/data/record");
    for (String name: args.keySet())
    	datasource.addParameter(name,args.get(name));
     DataSourceIntegerField id = new DataSourceIntegerField("fid", "ID");
    id.setValueXPath("@fid");
    id.setPrimaryKey(true);
    id.setRequired(true);
    DataSourceIntegerField parent = new DataSourceIntegerField("parent", "Parent");
    parent.setValueXPath("@parent");
    parent.setRequired(true);
    parent.setForeignKey("fid");
    parent.setRootValue("1");
    DataSourceBooleanField isFolder = new DataSourceBooleanField("isFolder", "IsFolder");
    DataSourceTextField name = new DataSourceTextField("name", "Name");
    name.setValueXPath("@name");
    name.setRequired(true);
    DataSourceDateField modified = new DataSourceDateField("modified", "Modified");
    DataSourceIntegerField size = new DataSourceIntegerField("size", "Size");
    DataSourceTextField icon = new DataSourceTextField("icon", "Icon");
    datasource.setFields(new DataSourceField[]{id,parent,name,isFolder,modified,icon,size});
    return datasource;
    	}

    #2
    Hi Pboysen,

    How are you trying to set the nameProperty such that you get an exception?

    Does the field you are trying to use as the nameProperty have unique values on a per-sibling set basis?

    Comment


      #3
      sibling names are unique

      Yes, this is a tree of filenames so the names are unique within a folder.
      Actually, the default property is "name" so I shouldn't have to set anything.

      treeGrid.getData().setNameProperty("name"); gives
      Code:
      java.lang.IllegalArgumentException: object is not an instance of declaring class
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
      	at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
      ...

      Comment


        #4
        I had the same problem. I think you shoul set Name property once data has arrived, hence, tree has been created. i.e.
        Code:
                        grdModules.addDataArrivedHandler(new DataArrivedHandler() {
        			
        			@Override
        			public void onDataArrived(DataArrivedEvent event) {
        				grdModules.getData().setNameProperty("title");
        			}
        		});
        although, docs say the default is "name", that didn't worked for me. You should explicitly set that property even if your data has a "name" property. Another thing is that Tree.getPath(TreeNode) returned me the path with a prefix "0_0/". I've just get rid of it with a replace.

        Cheers!

        Comment


          #5
          setNameProperty disable inline edit

          hI

          After i set the setNameProperty the cant edit. please provide a solution for it

          Comment

          Working...
          X