Editor in a dgrid tree

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Editor in a dgrid tree

Harry Devine
I have a dgrid with the tree mix-in.  In the grid, I want to make an editor where it shows a ComboBox on a certain column.  However, I only want the ComboBox to show up for a child element and not for the parent.  The parent should still expand as it always has.  I am capturing the .dgrid-content .dgrid-row:dblclick event, but I'm not sure how to tell the editor mix-in's canEdit function to only work for the child elements.  Any ideas?  Here's how I'm handling my grid currently:

        grid = new Grid({
          id: "Grid",
          columns: [
            tree({label: "Fac ID", field:"site"}),
                 {label: "City", field:"city"},
                 editor({label: "State", field:"state", canEdit:function() {return userCanEdit;}, editorArgs: {store:stateStore, style:"width:95px", labelAttr:"displaystate", searchAttr:"state"}}, ComboBox, "dblclick"),
          ],
          store: store,
          sort: [{attribute: "facid", descending:true}],
          query: {"type":"site"},
          rowsPerPage: 50,
          loadingMessage: "Retrieving data...",
          noDataMessage: "No data found!"
        }, "grid");

        /* Handle the grid double-click event; we don't want to put up a */
        /* ComboBox on a parent-level tree row.                          */
        grid.on(".dgrid-content .dgrid-row:dblclick", function(event) {
          console.log("Row type: ", grid.row(event).data.type);
        });


Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Editor in a dgrid tree

Harry Devine
OK, I think I found the answer and wanted to share.  I found that the canEdit function takes 2 parameters: object and value.  In my case, I only want to allow the edit if the row type is a certain type (I have a type for the parent and a separate type for the child in my store).  So I set the canEdit function to be as follows:

canEdit(object, value) {return object.type == "site";}

And it worked as I needed.

Thanks,
Harry



From: "Harry Devine" <[hidden email]>
To: [hidden email]
Sent: Wednesday, July 6, 2016 2:10:37 PM
Subject: [Dojo-interest] Editor in a dgrid tree

I have a dgrid with the tree mix-in.  In the grid, I want to make an editor where it shows a ComboBox on a certain column.  However, I only want the ComboBox to show up for a child element and not for the parent.  The parent should still expand as it always has.  I am capturing the .dgrid-content .dgrid-row:dblclick event, but I'm not sure how to tell the editor mix-in's canEdit function to only work for the child elements.  Any ideas?  Here's how I'm handling my grid currently:

        grid = new Grid({
          id: "Grid",
          columns: [
            tree({label: "Fac ID", field:"site"}),
                 {label: "City", field:"city"},
                 editor({label: "State", field:"state", canEdit:function() {return userCanEdit;}, editorArgs: {store:stateStore, style:"width:95px", labelAttr:"displaystate", searchAttr:"state"}}, ComboBox, "dblclick"),
          ],
          store: store,
          sort: [{attribute: "facid", descending:true}],
          query: {"type":"site"},
          rowsPerPage: 50,
          loadingMessage: "Retrieving data...",
          noDataMessage: "No data found!"
        }, "grid");

        /* Handle the grid double-click event; we don't want to put up a */
        /* ComboBox on a parent-level tree row.                          */
        grid.on(".dgrid-content .dgrid-row:dblclick", function(event) {
          console.log("Row type: ", grid.row(event).data.type);
        });


Thanks,
Harry

--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


--
Dojo Toolkit: http://dojotoolkit.org/
Tutorials: http://dojotoolkit.org/documentation/

[hidden email]
To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest
Loading...