2016-11-25 99 views
0

值如何在jqGrid的如何显示在jqGrid的

我JS网格中显示的键值对的值,

var source = { 
    localdata: vm.courseApplications, 
    datatype: 'array', 
    datafields: 
      [ 
       { 
       name: 'course.course_specialization.value', 
       type: 'string' 
       }, 
       { 
       name: 'subject_category', 
       type: 'string' 
       }, 

      ], 
    id: '_id' 
    }; 
    $scope.display_rows = vm.courseApplications.length; 
    var dataAdapter = new $.jqx.dataAdapter(source); 

    columns: [ 
     { 
     text: '', sortable: false, filterable: false, editable: false, 
     groupable: false, draggable: false, resizable: false, 
     datafield: '', columntype: 'number', width: 50, 
     cellsrenderer: function (row, column, value) { 
      return '<div class="jqxgridmargintop text-center">' + (value + 1) + '</div>'; 
     } 
     }, 
     { 
     text: 'Course Specialization', 
     datafield: 'course.course_specialization.value', 
     groupable: true, 
     editable: false, 
     cellsrenderer: vm.courseApplicationIdRender 
     }, { 
     text: 'Subject Category', 
     datafield: 'subject_category.value', 
     width: '10%', 
     groupable: false, 
     editable: false 
     }, 
    ], 

,我没有得到在网格中显示的任何值(显示为空值)。任何人都可以请建议help.Thanks。

+1

u能显示你想如何显示 –

回答

0

您可以使用colModel中的jsonmap属性。确切的实现可能取决于您在jqGrid中使用的datatype以及jqGrid的版本和分支。演示https://jsfiddle.net/OlegKi/vm1b132m/使用免费的jqGrid 4.13.5。它使用以下选项:

data: mydata.details, 
localReader: { id: "_id" }, 
colModel: [ 
    { name: "course_specialization", label: "Course", width: 200, 
     jsonmap: "course.course_specialization.value" }, 
    { name: "award", label: "Award", width: 120, 
     jsonmap: "course.award.value" }, 
    { name: "country", label: "Country", width: 100, 
     jsonmap: "course.country.value" }, 
] 
+0

奥列格您好,我得到这个错误“angular.js:13920无效的属性:colModel'” – MMR

+0

@nlr_p:抱歉,该代码,您发布的内容与jqGrid没有任何关系。 [旧答案](http://stackoverflow.com/a/29525862/315935)提供了一个使用Angular 1和jqGrid的例子,但是你可能需要使用* another * grid。 – Oleg