dojox.grid.datagrid - How to return values of an editable column in a Dojo DataGrid on an XPage? -


i have editable priority column in dojo datagrid. prior saving user's changes want verify handful of entries in grid, user has not set value priority field same value. is, in case set priority column [1,2,3,3,5] 5 rows in grid want raise alert reminding them priority column needs unique values.

the following code xe:viewitemfileservice grid:

<xe:restservice id="restservice1" jsid="restserviceobj"         pathinfo="pathinfo">         <xe:this.service>             <xe:viewitemfileservice defaultcolumns="true"                 contenttype="application/json" viewname="docsbyusername"                 var="rsentry" sortcolumn="priority"                 keys="#{sessionscope.username}">             </xe:viewitemfileservice>         </xe:this.service>     </xe:restservice>   

the following markup dojo datagrid editable priority column:

    <xe:djxdatagrid id="djxdatagrid1" singleclickedit="true"         jsid="gridobj" storecomponentid="restservice1" rowselector="20px">         <xe:djxdatagridcolumn id="djxdatagridcolumn1" field="username"             label="username" width="100px">         </xe:djxdatagridcolumn>         <xe:djxdatagridcolumn id="djxdatagridcolumn2" field="field1"             label="field1" width="100px">         </xe:djxdatagridcolumn>         <xe:djxdatagridcolumn id="djxdatagridcolumn3" field="fieldn"             label="fieldn" width="100px" editable="true">         </xe:djxdatagridcolumn>         <xe:djxdatagridcolumn id="djxdatagridcolumn4"             field="priority" label="priority" width="100px" editable="true"             celltype="dojox.grid.cells.select">             <xe:this.options><![cdata[#{javascript:var choices = ["1","2","3","4","5"];                                  return choices;}]]></xe:this.options>         </xe:djxdatagridcolumn>     </xe:djxdatagrid> 

i call following priorirityarray() function when user presses save button ....

<xp:scriptblock id="scriptblock3"> <xp:this.value><![cdata[ function priorityarray(){ var rsstore = restserviceobj; var grid = gridobj;  var rows = 0 ; var priorities = []; var item; var unid; var priority;      var actualrows = restserviceobj['_items'].length;      for(var = 0 ; < actualrows ; i++){       item  = grid.getitem(i);       if(item != null){         unid = item["@unid"];         priority = item["priority"];         priorities.push(item["priority"]);         rows = i;      }     };     return priorities;     };]]></xp:this.value> </xp:scriptblock> 

my problem in loop. item object being returned ear row in grid, item["fieldname"] calls returning nothing. have used notation in past in onrowclick event pass in rowindex arguments[0] object not work in script block in loop return entries.

btw, i'm not married looping approach if there easier way return current in-memory field/column values the gridobj or restserviceobj ears.

datagrid row item's values stored in object attributes within item.

enter image description here

change code to

    unid = item.attributes["@unid"];     priority = item.attributes["priority"];     priorities.push(priority); 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -