我在asp.net项目中使用Sigma grid。我想显示如果DB返回null则没有找到记录。我尝试了一些类似的事情:
var grid = Sigma.$grid(grid_demo_id);
var test1 = grid.dataset.getSize();
但它总是返回-1,无论是否是记录。
我正在粘贴下面的代码:
var grid_demo_id = "myGrid1";
var dsOption = {
fields: [
{ name: 'col1' },
{ name: 'col2' }
],
recordType: 'array'
}
var colsOption = [
{ id: 'col1', header: "Col1", width: 105 },
{ id: 'col2', header: "Col2", width: 131 }
];
var gridOption = {
id: grid_demo_id,
loadURL: 'Controller.aspx?P=Location&LocationId=' + globalLocation + '&' +strDate,
width: "448",
height: "239",
container: 'tabcontainer',
replaceContainer: true,
encoding: 'UTF-8', // Sigma.$encoding(),
dataset: dsOption,
columns: colsOption,
clickStartEdit: true,
defaultRecord: { 'col1': "00", 'col2': ""},
pageSize: 7,
pageSizeList: [7, 14, 21],
toolbarPosition: 'bottom',
toolbarContent: 'reload | nav | goto | pagesize | print '
};
var mygrid = new Sigma.Grid(gridOption);
Sigma.Util.onLoad(function () { mygrid.render() });
var grid = Sigma.$grid(grid_demo_id);
var test1 = grid.dataset.getSize();
alert(test1);
if (test1 === -1) {
alert('In');
document.getElementById('DivGridView').innerHTML = '<div id=\'divRec\'style=\'float:left;\'>No Record found.</div>';
document.getElementById('tabcontainer').style.display = "none";
}
else {
document.getElementById('tabcontainer').style.display = "block";
document.getElementById('DivGridView').style.display = "none";
}
答案 0 :(得分:0)
而不是使用grid.dataset.getSize(),使用下面的代码片段获取网格中存在的数据长度,如果为0,则可以打印所需的消息。
// sigma grid中的所有数据
var allSelectedRecords = myGrid.dataset.data;
//这将给出sigma网格中存在的行数
allSelectedRecords.length;