Saturday, 15 March 2014

dojo - Getting id from row clicked on a dgrid List -


I'm just starting to use dgrid, and going through the sample dTunes, I connected to each line Unable to locate ID. This is very curative on my part, but how can I get the ID sent from the data source? Define

  (['require', 'dgrid / list', 'dgrid / OnDemandGrid', 'doji / database / arrays', 'doji / stateful', 'doji / as' 'Dagrid / Selection', 'Digger / Keyboard', 'Dread / Extension / Column Hyder', 'Dojo / _base / Declare', 'Dojo / (Var, cstsNode, Dotor / Request Memory', 'Add-Selector / Put' , 'Dojo / Dome Readie!'), Function (Required, List, Grid, Selection, Keyboard, Header, Announced, Array, Used, = Put ​​(listNode, 'div # cstsCars'); ... Var cstsList = new tunes list ({}, cstsNode); var datacity Exacts = new request memory ({target: require.toUrl ('./datacsts.json')}) ... ... dataset. Ft (). Then (function (car) {cstsCars = arrayUtil.map (car, pickfield ( 'Details')); cstsCars.unshift ('all (' + cstsCars.length + 'CSTS cars' + (CstsCars.Length! == 1? 'S': '') + ')'); cstsList.renderArray CstsCars);}); ... cstsList.on ('dgrid-select', function (event) {var row = event.rows [0]; console.log (row.id); // line shows the number i How do I get real IDs or other areas? Console.log (row.data); // shows the line shown text ("sample text 1") console.log (row.data.id); // undefined}); Here is the snippet of sample data such as I am supplying:  
  [{"id": "221", "description": "sample "Sample text 2"}, {"id": "223", "description": "sample text 3"}]   / former> 

I want to see the ID instead, row Gives .id, 1,2 and 3, i.e. line number (or id dgrid created?).

You have not actually shown a complete example, but considering that you are in any way You are using the store, if you have to give your question to the DGRED for the store, you will have a much easier time. If you use dgrid / OnDemandList (or dgrid / list plus dgrid / extensions / pagination ), you can set your dataCSTS In the < collection store property, this will present it for you, and it will pick up your ID properly (since memory , and RequestMemory extensions, to use the id to define their default property).

The most appropriate place that you are currently doing before renderArray will probably be in the render line method if you are just using the list If not, there is no grid (the default bus in the list returns a text with the node that has been done in it; you will pass an object, so you want to lose the properties you want to display first.)

If you want a top row, showHeader: Consider implementing true setting renderHeader . (This is by default in the list by default, but the grid sets it to the correct and applies it.)

You may want to check out.


No comments:

Post a Comment