2014-09-08 2 views
0

나는 내 문제를 해결하기 위해 시도에 다음 포스트에서 제안을 시도 바인딩 . 내 배열에 행을 하드 코딩하면 그리드가 행을 완벽하게로드합니다. 그러나 AJAX 호출을 통해 데이터베이스에서 행을 가져 오려고하면 모눈에 행이로드되지 않습니다.Infragistics의 igGrid 데이터

alert("hey"); 

그리드 행이 잘로드 : 내 igGrid을 정의하기 직전에 내가 다음 줄을 추가 할 때 지금

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

    <script type="text/javascript"> 

     $(function() { 

      // user list is initially empty 
      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> 

: 여기 내 코드입니다. 그 경고 상자를 사용할 때 그리드가 작동하기 때문에 "GetUserList.ashx"의 코드가 제대로 작동하고 있다는 것을 알고 있습니다. 누군가 내가 여기에 잘못 될 수도있는 것에 대한 제안을 해줄 수 있습니까?

답변

1

내 표가 내 AJAX 호출이 응답을 보내는 것보다 빨리 초기화되는 것으로 밝혀졌습니다. 따라서 userList 배열에 그리드가 초기화 될 때 그 행이 없었습니다. 이 문제를 해결하기 위해 단순히 AJAX 함수의 "success"이벤트에서 그리드를 초기화하여 그리드가 초기화되기 전에 userList 배열에 데이터가 있음을 보증합니다.

http://www.infragistics.com/community/forums/t/91953.aspx

그들은 4 개 제안을 제공하고, 첫 번째가 저를 도와 준 하나입니다 : 여기

내가 Infragistics의에서 얻은 반응이다.

희망이 도움이되는 다른 사람에게 도움이되기를 바랍니다.

관련 문제