我在 asp.net 项目中使用Sigma 网格。如果数据库返回 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";
}