2011-08-01 5 views
1

점 "."을 갖는 속성이있는 json이 있습니다. 그것의 연산자. 메신저에서 그리드를 렌더링하려고하면 아무런 오류없이 공백으로 표시됩니다. 이 내 colModel도트 연산자로 jquery jqgrid propery

colModel : [ { 
     name : 'service.name', 
     search : 'true', 
     editable : true, 
     //index : 'service.name', 
     width : 200, 
     jsonmap : "cell.service.name"   
    }, 
    { 
     name : 'function.code', 
     search : 'true', 
     editable : true, 
     sortable:true, 
     //index : 'function.code', 
     width : 200, 
     jsonmap : "cell.function.code"   
    }], 

JSON 리더입니다

{ 
      "total":1, 
     "page":1, 
     "records":2, 
     "rows":[{ 
       "id":2110040, 
       "cell":{ 
       "function.code":"dsadad", 
         "service.name":"dsadasda" 

       } 
      }, 
      { 
       "id":2115040, 
       "cell":{ 
       "function.code":"iuiyuiy", 
        "service.name":"iyuiyuiy" 

       } 
      } 
     ] 
    } 

:

가 여기 내 JSON의

jsonReader : { 
     repeatitems : false, 
     root : "rows", 
     cell : "cell", 
     id : "id", 
     page : "page", 
     records : "records" 
    }, 

도와주세요, 내가 무슨 말이냐?

감사합니다.

답변

1

보십시오. here에 설명 된 문제에 가깝지만 XML 대신 JSON의 경우입니다.

문제는 jqGrid가 obj.cell['function.code'] 대신 obj.cell.function.code을 기준으로 행을 읽으려고한다는 것입니다. 당신이 the demo 접근 작업에 볼 수있는 방법을

colModel: [ 
    { 
     name: 'service_name', 
     search: 'true', 
     editable: true, 
     width: 200, 
     jsonmap: function (obj) { 
      return obj.cell['service.name']; 
     } 
    }, 
    { 
     name: 'function_code', 
     search: 'true', 
     editable: true, 
     sortable: true, 
     width: 200, 
     jsonmap: function (obj) { 
      return obj.cell['function.code']; 
     } 
    } 
] 

:있는 jqGrid가 제대로 당신이 jsonmap기능을 사용할 수있는 데이터를 읽을 수 있도록합니다.

+0

그게 효과가! 오렐 감사합니다. – user620339

+0

@ user620339 : 안녕하세요. – Oleg

+0

@ user620339 : 방법 [다른 데모] (http://www.ok-soft-gmbh.com/jqGrid/user620339_old.htm)에서 [이전 답변] (http://stackoverflow.com/questions/6853457)/jquery-jqgrid-renders-empty-table/6905206 # 6905206)도 작동합니다. – Oleg

0

난 당신이 흥미있는 질문을 찾아이

colModel : [ { 
     name : 'service.name', 
     search : 'true', 
     editable : true, 
     //index : 'service.name', 
     width : 200, 
     jsonmap : 'cell["service.name"]'   
    }, 
    { 
     name : 'function.code', 
     search : 'true', 
     editable : true, 
     sortable:true, 
     //index : 'function.code', 
     width : 200, 
     jsonmap : 'cell["function.code"]'   
    }], 
+0

Shankar, 나는 이것을 시험해 보았지만 동일한 빈 격자를 얻는다 !! – user620339

+0

도움이 될 내 수정 된 답변 희망을보십시오. – ShankarSangoli

+0

잘 시도해 보니 일하지 마라 !! – user620339