selection - Focusing or selecting the row, after grid load -
i have jsp page button. on clicking of button, creates dojo grid dynamically. after grid gets loaded, iterating through grid , if particular value there, whole row selected. i achieved using below code, row gets selected, getting error. error: "error: dojo.data.itemfilereadstore: invalid item argument" am using dojox.grid.datagrid(1.7)
here code create dynamic grid:
var ioargs = { url: "./dynamicdbservlet", content: { table_name:tablename,where_condn:condtn,columns:gridcolumnname,action:'select'}, handleas: "json", load: function(response) { //alert(response["items"][0].user_id); var tbl = document.getelementbyid(gridid); //alert(tbl); if(tbl) tbl.parentnode.removechild(tbl); var gridlayout = []; var key; colmn=gridcolumnname.split(','); var i=0; while(i<colmn.length) { if(colmn[i]=="status"){ key = colmn[i]; gridlayout.push({ field: key, name: displayname[i], formatter:function(opvalue){ //alert(opvalue); opvalue = parseint(opvalue); if(opvalue==1){ homecoming "executing";} if(opvalue==2){ homecoming "suspended";} if(opvalue==3){ homecoming "completed";} if(opvalue==4){ homecoming "aborted";} if(opvalue==5){ homecoming "error";} if(opvalue==6){ homecoming "terminated";}}, width: '200px', editable: false}); i++; }if(colmn[i]=="priority"){ key = colmn[i]; gridlayout.push({ field: key, name: displayname[i], formatter:function(opvalue){ if(opvalue==1){ homecoming "high";} if(opvalue==8){ homecoming "normal";} if(opvalue==15){ homecoming "low";} }, width: '200px', editable: false}); i++; }if(colmn[i]=="process_metadatype"){ key = colmn[i]; gridlayout.push({ field: key, name: displayname[i], formatter:function(opvalue){ if(opvalue==4497){ homecoming "provisioning sub process";} if(opvalue==4496){ homecoming "provisioning loop";} if(opvalue==4494){ homecoming "main process";} }, width: '200px', editable: false}); i++; }if(colmn[i]=="order_type"){ key = colmn[i]; gridlayout.push({ field: key, name: displayname[i], formatter:function(opvalue){ if(opvalue==4488){ homecoming "training order";} }, width: '200px', editable: false}); i++; }else{ key = colmn[i]; gridlayout.push({ field: key, name: displayname[i], width: '200px', editable: false}); i++; } } //alert(gridlayout); var gridstore = new dojo.data.itemfilewritestore({ data: response }); var dumm = dijit.byid('dynamicgrid'+tablename); if(dumm) { dumm.destroy(); } var finderresponse = new dojox.grid.datagrid({ id:"dynamicgrid"+tablename, query: { }, store:gridstore, structure: gridlayout, selectionmode: "single" }, document.createelement("div")); dojo.byid(parentdiv).appendchild(finderresponse.domnode); //var varb=dijit.byid("finderresponsegrid"+tablename); //alert(varb); //varb.layout.setcolumnvisibility(0, false); gbshowgridflag = true; finderresponse.startup(); //dijit.byid('dynamicgridcwprocess').focus.setfocusindex(0); try{ for( var i=0; < dijit.byid('dynamicgridcwprocess').rowcount; i++){ var items = dijit.byid('dynamicgridcwprocess').getitem(i); var value=dijit.byid('dynamicgridcwprocess').store.getvalue(items,"process_id"); if(value=="2507"){ dijit.byid('dynamicgridcwprocess').selection.setselected(i,true); } } if(definedbl){ getprocessgrid(); } }catch(e){ alert(e); } }, error: function(error) { alert("an unexpected error occurred: " + error); } }; var deferred = dojo.xhrpost(ioargs);
this code help me select row in grid :
grid.selection.select(rowindex);
in case:
finderresponse.selection.select(rowindex);
i hope solve problem.
grid selection dojo dojox.grid.datagrid
No comments:
Post a Comment