|
Title: How can I select a row in DataGrid GroupView after "clearSelections" [Solved] Post by: cdy328 on February 26, 2015, 01:55:28 AM I have already set "view:groupview",but the following codes doesn't work:
Thanks in advance :). $("#xxx").datagrid({ ... ... onLoadSuccess:function(){ var dg = $(this); checkedItems=dg.datagrid("options").checkedItems; for(var i=0;i<checkedItems.length;i++){ // this row doesn't work dg.datagrid("checkRow",dg.datagrid("getRowIndex",checkedItems.id)); ... ... } } Title: Re: How can I select a row in DataGrid GroupView? Post by: stworthy on February 26, 2015, 07:07:34 AM Please check if you can get the row index correctly before calling the 'checkRow' method.
Code: var index = dg.datagrid("getRowIndex",checkedItems.id);Title: Re: How can I select a row in DataGrid GroupView? Post by: cdy328 on February 26, 2015, 06:34:46 PM 1. sorry,the forum can't show "[]",my code is "checkedItems[ i ].id"
I don't know why,but I'm sure I can get the correct row index. I select the first row,and the row index is "0". 2. I use the debugger "F12",find that the row can "select",but when goes to "function initCss()",then the selected row turns to "unSelect" 3. I changed my code to this,even doesn't work, I don't know what else affect this datagrid onLoadSuccess:function(){ $(this).datagrid('selectRow',0); $(this).datagrid('checkRow',0); $(this).datagrid('checkRow',1); } Title: Re: How can I select a row in DataGrid GroupView? Post by: cdy328 on February 27, 2015, 12:39:12 AM I have other codes,may be they are the reason that affect the above :)
because some other bugs,I must "clearSections" after "loadData". I have tested that the datagrid's "onLoadSuccess" runs after the function "refreshAllTables()", but the codes in "onLoadSuccess" doesn't work, what else should I do, can I select a row after "clearSections" in function "refreshAllTables()" ? $(document).ready(function(){ refreshAllTables(); }); function refreshAllTables(){ ... ... ajax_request("/userworkspace/ajax_items_to_first_assign",{},function(result){ $("#table_items_by_task").datagrid("loadData",result); $("#table_items_by_task").datagrid("clearSelections"); ... ... },0); } Title: Re: How can I select a row in DataGrid GroupView? Post by: stworthy on February 27, 2015, 01:10:28 AM Please refer to this example http://jsfiddle.net/0obkvg85/. It works fine.
Title: Re: How can I select a row in DataGrid GroupView? Post by: cdy328 on March 02, 2015, 09:41:53 PM Thanks.
1. The above code is well,but it have no "clearSelections", and when I execute the function "clearSelections" in my function "refreshAllTables": the above code can "check" a row,but can't "select" a now. And I don't know when the "clearSelections" finished,does "clearSelections" have the function like "onLoadSuccess"? 2. And I have another question,that I can't expand a group in "onLoadSuccess", after "clearSelections" onLoadSuccess:function(){ $(this).datagrid('selectRow',0); $(this).datagrid('checkRow',0); $(this).datagrid('checkRow',1); for(var j=0;j<groupIndex.length;j++){ $(this).datagrid('expandGroup',groupIndex[ j ]); } } function refreshAllTables(){ ... ... ajax_request("/userworkspace/ajax_items_to_first_assign",{},function(result){ $("#table_items_by_task").datagrid("loadData",result); $("#table_items_by_task").datagrid("clearSelections"); ... ... },0); } 3. I think that the execution sequence is "clearSelections"-"datagrid's onLoadSuccess", but the result is not,how can I control after the "clearSelections" finished? Expect you answer :) Title: Re: How can I select a row in DataGrid GroupView? Post by: stworthy on March 03, 2015, 08:56:57 AM Please notice your code:
Code: $("#table_items_by_task").datagrid("loadData",result); http://jsfiddle.net/0obkvg85/1/ Title: Re: How can I select a row in DataGrid GroupView? Post by: cdy328 on March 03, 2015, 11:20:15 PM Thanks :)
It solved all the problems,and that method provide a new idea. |