jQuery 如何创建一个 jqGrid

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4276936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 16:58:11  来源:igfitidea点击:

How to create a jqGrid

jqueryjqgrid

提问by Ahmad Farid

I need to get to know how to create a very simple jqGrid just to get used to javascript and jQuery. I have been searching online but unable to find any resources which explain that. so a simple example would be great or a link to a tutorial.

我需要了解如何创建一个非常简单的 jqGrid 以适应 javascript 和 jQuery。我一直在网上搜索,但找不到任何解释这一点的资源。所以一个简单的例子会很棒或者一个教程的链接。

回答by Eric Hogue

The easiest gird you can create with jqGrid is probably the one populated by an array. You can find an example here. But basically all you need is this:

您可以使用 jqGrid 创建的最简单的网格可能是由数组填充的网格。您可以在此处找到示例。但基本上所有你需要的是:

var mydata = [
        {id:"1"}
        ];
jQuery("#list4").jqGrid({
datatype: "local",
height: 250,
colNames:['Inv No'],
colModel:[
    {name:'id',index:'id', width:60, sorttype:"int"}

],
caption: "Manipulating Array Data", 
    data: mydata
 });

You can find all the information you need in the jqGrid wiki.

您可以在jqGrid wiki 中找到您需要的所有信息。

EDIT:

编辑:

I fixed the bugs pointed out by Oleg and used the new data parameter. Ahmad: You can do this in an included js file or in your html between tags. You should really look at the examples and look at the source of the demo pages.

我修复了 Oleg 指出的错误并使用了新的数据参数。Ahmad:您可以在包含的 js 文件中或在标签之间的 html 中执行此操作。您应该真正查看示例并查看演示页面的来源。