java - display new row at first row inside dataGrid or focus on the newly added row -


my requirement add new row @ first row of grid inside datagrid on click of add row button. can able add new row inside grid, want add/display new row in first row of grid each time when user click add row button. when user want add new row , been displayed after existing rows can seen in fiddle : http://jsfiddle.net/q9gyv/59/. please suggest how can display the new added row in first row of existing data grid or if added @ last row shown in fiddle, focus on newly added row user.

below sample code:

require(['dojo/_base/lang', 'dojox/grid/datagrid', 'dojo/data/itemfilewritestore', 'dijit/form/button', 'dojo/dom', 'dojo/domready!'],  function (lang, datagrid, itemfilewritestore, button, dom) {     /*set data store*/     var data = {         identifier: "id",         items: [{             id : 1,             col2 : "aa",             col3 : "bb",             col4 : "cc"          }]     };      var store = new itemfilewritestore({         data: data     });      /*set layout*/     var layout = [         [{             'name': 'column 1',                 'field': 'id',                 'width': '100px'         }, {             'name': 'column 2',                 'field': 'col2',                 'width': '100px'         }, {             'name': 'column 3',                 'field': 'col3',                 'width': '200px'         }, {             'name': 'column 4',                 'field': 'col4',                 'width': '150px'         }]     ];      /*create new grid*/     var grid = new datagrid({         id: 'grid',         store: store,         structure: layout,         rowselector: '20px'     });      /*append new grid div*/     grid.placeat("griddiv");      /*call startup() render grid*/     grid.startup();      var id = 2;      var button = new button({         onclick: function () {             console.log(arguments);             store.newitem({                 id: id,                 col2: "col2-" + id,                 col3: "col3-" + id,                 col4: "col4-" + id             });             id++;         }     }, "addrow"); }); 

you can set sortinfo property of grid -1 sort grid first column in descending order , force sort after renderrow dojo/aspect

aspect.after(grid, 'renderrow', grid.sort); 

http://jsfiddle.net/richayotte/740l0y43/

if possible, use dgrid. dojox/grid/datagrid or deprecated.


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

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

sorting - opencl Bitonic sort with 64 bits keys -