jqGrid动态列 [英] jqGrid dynamic columns

查看:65
本文介绍了jqGrid动态列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jqGrid v4.4.5,我想用动态列创建它. 它由"jqGridHandler.ashx"文件填充. 我想通过JSON发送所有信息(列名,数据等). 我在Google中搜索它,但是找不到一个好的答案.

I use jqGrid v4.4.5 and I want to create it with dynamic columns. It is filled by "jqGridHandler.ashx" file . I want send all information(column name,data,...) by JSON . I search for it in Google but can not find a good answer.

通过单击每个节点(子节点)来更改整个网格(动作和列...).例如,通过单击node3,网格具有三列``A'',``B''和``actions'',但是通过单击node2网格具有列"C","D"和动作".

By Click on each node(child) change whole grid(actions and columns...).For example by click on node3 the grid has three columns 'A' and 'B' and 'actions' but by click on node2 grid has columns 'C' and 'D' and 'actions'.

推荐答案

一个人可以使用jqGrid创建许多不同的网格,树形网格,子网格等.了解您要显示10行还是100000行的网格非常重要.如果您有100000行(或其他大量行),则必须实现服务器端分页和数据排序.因此,如果用户单击下一页"按钮,则应该从服务器加载下一行.为什么您需要在分页或排序时发送所有colModel数据?因此,您应该清楚地了解到,在服务器端场景中,只需创建一次网格的所有结构一次,然后只需刷新网格主体即可.因此,一次发送所有信息(列名,列模型,数据等)是个不好的选择.

One can use jqGrid to create many different grids, tree grids, subgrids and so on. It's very important to understand whether you want to display grid with 10 rows or with 100000 rows. If you have 100000 rows (or some other large number of rows) you will have to implement server side paging and sorting of data. So if the user would click on the "next page" button the next rows should be loaded from the server. Why you would need to send all colModel data on paging or sorting? So you should clear understand that in server side scenario one need create all structures of grid only once and then one need refresh only the body of grid. So it would be bad choice to send all information (column name, column model, data,... at once).

仅当网格中有几百或几千行并且可以使用loadonce: true选项时,它们才可以加载一次所有信息(列名,列模型,数据等). .)每个单独的jQuery.ajax调用,然后使用datatype: "local"并使用包含所有网格数据的data参数创建jqGrid.

Only if you have some hundreds or some thousand of rows in the grid and you can use loadonce: true option them you can load once all information (column name, column model, data, ...) per separate jQuery.ajax call and then create jqGrid with datatype: "local" and using data parameter which contains all grid data.

已更新:如果需要更改

// in the example below the grid with id="list" will be created 
// with column having name: "c4" in colModel
var $grid = $("#list"), columnName = "c4";

...

var $colHeader = $("#jqgh_" + $.jgrid.jqID($grid[0].id) + "_" + $.jgrid.jqID(columnName)),
    $sortingIcons = $colHeader.find(">span.s-ico");

// change the text displayed in the column 
$taxHeader.text("New header text");

// append sorting icons to the new text
$taxHeader.append($sortingIcons);

这篇关于jqGrid动态列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆