开发者

jqGrid - how to add custom properties to a grid

How can you add custom properties to a grid?

The properties would not be used by 开发者_JAVA技巧jqGrid itself. It's more of meta data which would be used by our custom code.

For example, we want a custom property to identify if the grid appears on our 'main page'. This property would be read by some of our common functions which would handle certain tasks differently depending on if the grid is on the main page.

Can you just do something like:

mygrid.onMainPage = true;

?? Not sure if that is valid JavaScript or would mess up jqGrid somewow.


You just add them. Works fine. Try:

$("#myGrid").jqGrid({
    url: "/Data", // usual "standard" properties
    myCustomProperty: "Hi there!"
});

Now you can access them:

var mcp = $("#myGrid").jqGrid("getGridParam", "myCustomProperty");

For a real-world example, look at my jqGrid.history plugin.


You should look into jQuery .Data

http://api.jquery.com/jQuery.data/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜