jqGrid:在将HTML表格转换为网格时启用分页 [英] jqGrid: Enable paging while converting HTML table to grid

查看:148
本文介绍了jqGrid:在将HTML表格转换为网格时启用分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一直在如何将html表转换为可分类和排序的东西,并且我偶然发现了jqGrid jquery插件。到目前为止,我已经了解到,我们必须调用 tableToGrid()来转换表(我们将其作为jQuery选择器字符串传递给方法)。我也尝试了很多其他的东西,例如:

  tableToGrid('#GridView1'); 

$('#GridView1')。jqGrid({
rowNum:10,
pager:'#pager',
rowList:[10,20,30 ]
});

但所有这些都不能为我提供正确的结果。当我们将html表格转换为网格时,是否可以进行分页?

解决方案

您应该尝试使用

  tableToGrid('#GridView1',{
rowNum:10,
pager:'#pager',
rowList:[10 ,20,30]
});

您还可以添加更多jqGrid选项作为 tableToGrid 的第二个参数。 code>。对于
<$转换之后,您还可以获取引用到jqGrid的 colModel p $ p> var cm = myGrid.getGridParam(colModel);

然后修改列模型的一些参数。



更新:例如对于以下代码,您可以设置一些列数据为 edittype:select

  for(var i = 0,l = cm.length; i <1; i + = 1){
var colModelColumn = cm [i];
//搜索名称为colModelColumnName的clolumn。
//变量colModelColumnName和selectedOptions被定义
//在另一个代码片段之上
if(colModelColumn.name === colModelColumnName){
jQuery.extend(colModelColumn, {edittype:select,
editoptions:{value:selectedOptions}});
休息;
}
}


Been googling all this while on how to convert an html table to something pagable and sortable, and I have stumbled across jqGrid jquery plugin. I've learned so far that we have to call tableToGrid() to convert the table (which we pass as a jquery selector string to the method). I've also tried a host of other things, like for e.g:

tableToGrid('#GridView1');

$('#GridView1').jqGrid({
    rowNum: 10,
    pager: '#pager',
    rowList: [10,20,30]
});

But all these do not provide me with the proper result. Is paging possible when we convert an html table to grid?

解决方案

You should try with

tableToGrid('#GridView1', {
    rowNum: 10,
    pager: '#pager',
    rowList: [10,20,30]
});

You can also add more jqGrid options as the second parameter of tableToGrid. You can also get reference to the colModel of the jqGrid after conversion with respect of

var cm = myGrid.getGridParam("colModel");

and then modify some parameters of the column model.

UPDATED: for example with the following code you can set some column data as edittype: "select".

for (var i = 0, l=cm.length; i < l; i += 1) {
    var colModelColumn = cm[i];
    // search for the clolumn with the name colModelColumnName.
    // variables colModelColumnName and selectedOptions are defined
    // in another code fragment above this one
    if (colModelColumn.name === colModelColumnName) {
        jQuery.extend(colModelColumn, { edittype: "select",
                                        editoptions: { value: selectedOptions }});
        break;
    }
}

这篇关于jqGrid:在将HTML表格转换为网格时启用分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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