2

I am using Sigma grid in an asp.net project. I want to display that no record is found if the DB returns null. I have tried a few things like:

var grid = Sigma.$grid(grid_demo_id);
var test1 = grid.dataset.getSize();

But it always return -1 whether are are records or not.

I am pasting my code below:

 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";
        }
w.brian
  • 16,296
  • 14
  • 69
  • 118

1 Answers1

0

instead of using grid.dataset.getSize(), use the below snippet to get the length of data present in grid and if it is 0, you can print the desired message.

//All data present in sigma grid

var allSelectedRecords = myGrid.dataset.data;

//this will give the number of rows present in sigma grid

allSelectedRecords.length;

LalitKumar
  • 11
  • 2