如何在jqgrid中显示值

时间:2016-11-25 07:52:46

标签: jquery angularjs jqgrid

如何在jqgrid中显示键值对的值

我的js for grid,

 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
      },
    ],

我没有在网格中显示任何值(显示空值)。任何人都可以建议帮助。谢谢。

1 个答案:

答案 0 :(得分:0)

您可以在jsonmap中使用colModel属性。确切的实现可能取决于您在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" },
]