jqGrid在客户端排序

jqGrid sorting on client side(jqGrid在客户端排序)

本文介绍了jqGrid在客户端排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自动加载行的树形网格.目标是在客户端上按树列对网格进行排序.

I have a tree-grid with autoloading rows. The goal is to sort the grid by tree column, right on client side.

但每次我单击排序列标题时,它发出一个 Ajax 调用以进行排序,但我只需要使用本地数据进行就地排序.

But each time I click on sort column header, it issues an Ajax call for sorting, but all I need is on-place sorting using the local data.

我是否有不正确的网格参数或树不适用于树列上的客户端排序?

Do I have incorrect grid parameters or doesn't tree work with client-side sorting on tree column?

当前用于排序的 jqGrid 参数是:

Current jqGrid params for sorting are are:

loadonce: true, // to enable sorting on client side
sortable: true //to enable sorting

推荐答案

为了让客户端排序工作,我需要在加载网格后调用 reloadGrid:

To get client-side sorting to work, I needed to call reloadGrid after the grid was loaded:

loadComplete: function() {
    jQuery("#myGridID").trigger("reloadGrid"); // Call to fix client-side sorting
}

我不必在我的应用程序的另一个网格上执行此操作,因为它被配置为使用通过另一个 AJAX 调用检索的数据,而不是直接由网格检索的数据:

I did not have to do this on another grid in my application because it was configured to use data retrieved via another AJAX call, instead of data retrieved directly by the grid:

editurl: "clientArray"
datatype: "local"

这篇关于jqGrid在客户端排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:jqGrid在客户端排序

基础教程推荐