return $r; } /** * @param int $page 页数 * @param int $pagesize 每页显示数量 * @return mixed */ function link_find($page = 1, $pagesize = 100) { $arr = link__find($cond = array(), array('rank' => -1), $page, $pagesize); return $arr; } /** * @param $id * @return bool 返回FALSE失败 TRUE成功 */ function link_delete($id) { if (empty($id)) return FALSE; $r = link__delete(array('id' => $id)); link_delete_cache(); return $r; } //--------------------------kv + cache-------------------------- /** * @return mixed 返回全部友情链接 */ function link_get($page = 1, $pagesize = 100) { $g_link = website_get('friends_link'); if (empty($g_link)) { $g_link = link_find($page, $pagesize); $g_link AND website_set('friends_link', $g_link); } return $g_link; } // delete kv and cache function link_delete_cache() { website_set('friends_link', ''); return TRUE; } ?>javascript - Callback for When jqGrid Finishes Reloading? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Callback for When jqGrid Finishes Reloading? - Stack Overflow

programmeradmin5浏览0评论

I am using the jqGrid plug-in and at one point I need to refresh the grid and set the selected row to match the record that I am showing in detail on another section of the page. I have the following code but it does not work:

$("#AllActions").trigger("reloadGrid").setSelection(selectedRow);

The selectedRow parameter es from an event handler that gets called when the data is changed and the grid needs to be updated.

I'm pretty sure that the problem is that the grid is not loaded when the selection is being set, because if I put a call to alert() between the calls to trigger() and setSelection(), it works.

I would be grateful for any advice.

[Edit]Looks like jqGrid's setSelect does not work after reloadGrid is related but did not get resolved.[/Edit]

I am using the jqGrid plug-in and at one point I need to refresh the grid and set the selected row to match the record that I am showing in detail on another section of the page. I have the following code but it does not work:

$("#AllActions").trigger("reloadGrid").setSelection(selectedRow);

The selectedRow parameter es from an event handler that gets called when the data is changed and the grid needs to be updated.

I'm pretty sure that the problem is that the grid is not loaded when the selection is being set, because if I put a call to alert() between the calls to trigger() and setSelection(), it works.

I would be grateful for any advice.

[Edit]Looks like jqGrid's setSelect does not work after reloadGrid is related but did not get resolved.[/Edit]

Share Improve this question edited May 23, 2017 at 10:32 CommunityBot 11 silver badge asked May 13, 2010 at 16:38 JamesJames 8197 silver badges23 bronze badges 1
  • 1 I written just now an answer in stackoverflow./questions/2529581/… too. – Oleg Commented May 13, 2010 at 16:56
Add a ment  | 

2 Answers 2

Reset to default 5

Firts of all you should save rowid of the old selection in a variable, then call $("#AllActions").trigger("reloadGrid") and inside of loadComplete event handler set selection with respect of $("#AllActions").setSelection(rowid).

Don't forget to set option scrollrows:true of the jqGrid, to be sure that the selected row will be visible.

Try this, I did it, and it works.

setTimeout("$('#grid').jqGrid('setSelection','"+id+"')", 1000); 

and of course in the config of the master grid.. you can use somthing like this

onSelectRow: function(ids) { 
  if(ids == null) { 
    ids=0; 
    if($("#grid-detail").jqGrid('getGridParam','records') >0 ) { 
        $("#grid-detail").jqGrid('setGridParam',{url:"server.php?&grid=1&oper=get_records&id=&id="+ids,page:1}); 
        $("#grid-detail").jqGrid().trigger('reloadGrid'); 

    } 
  } else { 
        var arr = jQuery("#list-maestro").getRowData( ids );
        var id = arr.id; 
        $("#grid-detail").jqGrid('setGridParam',{url:"server.php?&grid=1&oper=get_records&id="+id,page:1}); 
        $("#grid-detail").jqGrid().trigger('reloadGrid'); 
  }
}
发布评论

评论列表(0)

  1. 暂无评论