Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
815
igGrid Data Binding
posted

I am new to the Infragistics JQuery controls.

I have an igGrid that is using a javascript array of JSON objects as its data source. When I hard code rows into the array, the grid loads the rows just fine. But when I try to load data from my database, the grid will not load any rows. Here is the code I'm using to get rows from my database and load them into the grid:

<table id="grid"></table>

<script type="text/javascript">

  $(function () {

     // one hard coded row

     var userList = [];

               

    

          // get user list

          $.ajax({

        type: "POST",

        contentType: "application/json; charset=utf-8;",

        url: "/AJAX_Handlers/GetUserList.ashx",

        dataType: "json",

        success: function (Result) {

           // load the user list

           $.each(Result, function (i, item) {

           userList[i] = { "Name": Result[i]["Name"], "Email": Result[i]["Email"], "OPhone": Result[i]["OPhone"], "CPhone": Result[i]["CPhone"], "HPhone": Result[i]["HPhone"], "FPhone": Result[i]["FPhone"], "Address1": Result[i]["Address1"], "Address2": Result[i]["Address2"], "City": Result[i]["City"], "ZIP": Result[i]["ZIP"], "Active": Result[i]["Active"], "Contractor": Result[i]["Contractor"] };

});

     },

     failure: function (arg1, arg2) {

        alert(arg1 + '\n\n' + arg2);

     },

     error: function (Result, Error, arg3, arg4) {

        alert(Result + '\n\n' + Error + '\n\n' + arg3 + '\n\n' + arg4);

     }

});



     // define grid properties

     $("#grid").igGrid({

             columns: [

        { headerText: "Name", key: "Name", dataType: "string" },

        { headerText: "Email", key: "Email", dataType: "string" },

        { headerText: "Office #", key: "OPhone", dataType: "string" },

        { headerText: "Cell #", key: "CPhone", dataType: "string", hidden: "true" },

        { headerText: "Home #", key: "HPhone", dataType: "string", hidden: "true" },

        { headerText: "Fax #", key: "FPhone", dataType: "string", hidden: "true" },

        { headerText: "Address", key: "Address1", dataType: "string", hidden: "true" },

        { headerText: "Apt/Suite", key: "Address2", dataType: "string", hidden: "true" },

        { headerText: "City", key: "City", dataType: "string" },

        { headerText: "State", key: "StateName", dataType: "string" },

        { headerText: "ZIP", key: "ZIP", dataType: "string" },

        { headerText: "Active", key: "Active", dataType: "bool" },

        { headerText: "Contractor", key: "Contractor", dataType: "bool" }

             ],

      width: "100%",

      height: "400px",

      autoGenerateColumns: false,

      renderCheckboxes: true,

             dataSource: userList

     });

  });

</script>



I know that the GetUserList.ashx code is working properly because when I add the following line:


alert("hey");


before I define my igGrid, the grid WILL load the data just fine!