我有一个 jqGrid 表的问题,我无法找到解决方案,也无法找到引导我正确方向的答案,我已经阅读了 SO 中的一些答案,但没有一个专注于我的问题:
到目前为止,我阅读的许多相关问题都集中在使用 JSON 数据填充网格,但这不是我的情况。我填充网格的方式是使用addRowData
方法,它似乎有效,因为当我在浏览器的调试工具(Chrome 29.0.1547.76 m table
)tbody
和tr
元素都存在预期的数据,但它们不可见!
所有行的宽度和高度均为 0px 值,这就是为什么(我想)数据不显示的原因。但是我使用相同的方法来显示另一个表并且结果是可见的。
我无法粘贴所有代码,因为它很乱而且乱七八糟,但我会尝试提供有用的信息:
// The ConvertTojqGrid method converts the data (array object)
// into the format expected by jqGrid in order to provide the
// colModel and rows
var jqGridData = ConvertTojqGrid(data);
// the divID begins with '#'
var div = jQuery(divID)[0];
var table = divID + '_table'
jQuery(divID).append('<table id="' + table.substr(1) + '"></table>');
// get rid of the '#' in the string ^^^^^^^^^^^^^^^
jQuery(table).jqGrid(
{
autowidth: true,
gridview: true,
headertitles: true,
datatype: 'clientSide',
caption: gridCaption,
colModel: jqGridData.colModel,
records: jqGridData.rows.length,
height: div.clientHeight,
width: div.clientWidth
});
jqGridData.rows.forEach(function(row)
{
jQuery(table).addRowData('row_id', row);
});
该网页显示了一个表格,其中包含按预期显示的数据但隐藏了一些列,在表格的左上方放置了一个按钮,该按钮显示了一个带有另一个网格的表格,该表格显示相同的表格而没有隐藏的列。
所有表格都放置在运行时生成的文件中div
,并在其中生成div
一个table
标签以包含网格。
简而言之,问题不在于获取数据,也不在于填充表格,问题在于数据正确并且表格已填充但行不可见。
任何建议都会受到欢迎。