如何使用迷你图填充 jqGrid 单元格
我无法找出在 jqgrid 单元格中渲染迷你图的正确方法,而且我一生都无法在任何地方找到任何相关示例。
不管怎样,经过一些研究,我决定要做的就是尝试在 afterRowInsert 上将迷你图注入到单元格中。不幸的是我做错了。这就是我正在做的事情:
afterInsertRow: function(rowid, rowdata, rowelem) {
var cell = jQuery('#datapointlist').getCell(rowid, 'Graph');
$(cell).sparkline([1,34,3,2,1])
},
插入时单元格的内容是“正在加载”,并且在事件发生后它保持不变。我什至不确定这是否是尝试使其正常工作的最佳方法,因此如果有人可以帮助我,我将不胜感激。
I'm having trouble figure out the proper way to get a sparkline graph rendering in a jqgrid cell and can't for the life of me find any relevant samples anywhere.
Anyway, after some research I decided the thing to do was try injecting the sparkline graph into the cell on afterRowInsert. Unfortunately I am doing it wrong. Here is what I am doing:
afterInsertRow: function(rowid, rowdata, rowelem) {
var cell = jQuery('#datapointlist').getCell(rowid, 'Graph');
$(cell).sparkline([1,34,3,2,1])
},
The contents of the cell on insertion is 'Loading' and after the event it remains unchanged. I'm not really even sure if this is the best way to try to get this working so if anyone can help me out it would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我之前没有听说过 jQuery Sparkline,但在互联网上简单的搜索就给出了答案。在我看来,插件的使用非常简单。
第一个问题是我们从哪里获取将显示为迷你图的数据。我放置了像
[1,34,3,2,1]
这样的数组,我们将使用它来将迷你图初始化为列中的字符串,该列将包含末尾的行。所以我将"[1,34,3,2,1]"
放入相应的单元格中。然后在loadComplete
内部我得到单元格包含将其转换为数组 jQuery.parseJSON 并调用sparkline
。结果我收到了以下网格:您可以实时查看网格 此处。
您可以在下面找到我使用的代码:
I did't hear before about jQuery Sparkline, but simple search in Internet gives the answer. It seems to me the usage of the Plugin is very simple.
The first problem is from where we would get the data which we will show as sparkline. I placed the array like
[1,34,3,2,1]
which we will use to initialize the sparkline as a string in the column which will contain the lines at the end. So I placed"[1,34,3,2,1]"
in the corresponding cell. Then inside ofloadComplete
I get the cell contain convert it to the array with respect of jQuery.parseJSON and callsparkline
. As the result I received the following grid:You can see the grid live here.
Below you can find the code which I used: