2012-05-16 3 views
0

SQL 데이터 바인딩 및 largejsonresult와 함께 작동하도록 jqxGrid를 가져 오는 데 문제가 있습니다. 여기에 현재 코드가 있습니다.jqxGrid with SQL Binding 및 LargeJsonResult가 비어 있습니다.

컨트롤러 :

public LargeJsonResult GetCustomers() 
    { 
     var dbResult = db.CPTs.ToList(); 
     var customers = from customer in dbResult 

         select new 
         { 
          customer.CPT1, 
          customer.MOD, 
          customer.SDESC, 
          customer.FAGE, 
          customer.TAGE 
         }; 
     return new LargeJsonResult { Data = customers, JsonRequestBehavior = System.Web.Mvc.JsonRequestBehavior.AllowGet }; 
    } 

보기 : 내가 직접 dbCPT/GetCustomers를 실행하면

<script type="text/javascript"> 
    $(document).ready(function() { 
     // prepare the data 
     var source = { 
      datatype: "json", 
      datafields: [{ name: 'CPT1' }, { name: 'MOD' }, 
      { name: 'SDESC' }, { name: 'FAGE' }, { name: 'TAGE' }, ], 
      url: 'dbCPT/GetCustomers' 
     }; 
     $("#jqxgrid").jqxGrid({ 
      source: source, 
      theme: 'classic', 
      columns: [{ text: 'Company Name', datafield: 'CompanyName', 
       width: 250 
      }, { text: 'CPT Code', datafield: 'CPT1', width: 150 }, 
{ text: 'Short Description', datafield: 'SDESC', width: 180 }, 
{ text: 'FAGE', datafield: 'From Age', width: 200 }, 
{ text: 'TAGE', datafield: 'To Age', width: 120}] 
     }); 
    }); 
</script> 

<h2>Index</h2> 
<div id="jqxgrid"></div> 

나는 당기는거야하지만 아무것도 그리드 때 표시되지 않습니다 모든 데이터를 출력 파일을 얻을 dbCPT 페이지로 이동합니다.

내 코드가 더 필요하면 알려 주시기 바랍니다.

감사합니다.

+0

jqxGrid의 [jqwidgets] (http://www.jqwidgets.com/) 및 jqGrid는 ** 다른 ** 제품입니다. 그래서 귀하의 질문에 잘못된 태그를 사용했습니다. – Oleg

+0

qjxgrid 및 qjwidgets는 새로운 태그로 간주되었으므로 사이트를 처음 사용하기 때문에이를 사용하지 않을 것입니다. 제 사과, jqgrid가 가장 가까운 곳이었습니다. –

답변

0

그 작품을 만들었습니다. 코드에서 jqxDataAdapter를 사용하고 있지만 필요하지 않다고 생각합니다.

자바 스크립트

var source = { 
    datatype: "json", 
    datafields: [{ name: 'CompanyName' }, { name: 'ContactName' }, 
    { name: 'ContactTitle' }, { name: 'Address' }, { name: 'City'} ], 
    url: 'Customers/GetCustomers' 
}; 
var dataAdapter = new $.jqx.dataAdapter(source); 

$("#jqxgrid").jqxGrid({ 
    source: dataAdapter, 
    theme: 'classic', 
    columns: [{ text: 'Company Name', datafield: 'CompanyName', width: 250 }, 
       { text: 'Contact Name', datafield: 'ContactName', width: 150 }, 
       { text: 'Contact Title', datafield: 'ContactTitle', width: 180 }, 
       { text: 'Address', datafield: 'Address', width: 200 }, 
       { text: 'City', datafield: 'City', width: 120}] 
}); 

C#

public LargeJsonResult GetCustomers2() 
{ 
    var dbResult = db.Customers.ToList(); 
    var customers = from customer in dbResult 
        select new 
        { 
         customer.CompanyName, 
         customer.ContactName, 
         customer.ContactTitle, 
         customer.Address, 
         customer.City 
        }; 
    return new LargeJsonResult { Data = customers, JsonRequestBehavior = System.Web.Mvc.JsonRequestBehavior.AllowGet }; 
} 

당신이 (가) jqxGrid의 마지막 버전과 LargeJsonResult의 적절한 구현을 사용하고 있는지 확인합니다.

+0

우리는 컴퓨터 개체가 키 값 쌍으로 구성원을 포함하고있는 것과 어떻게 동일한 작업을 수행합니까? 약간의 도움이 필요하다. –