Author Topic: fetch colModel from server side  (Read 517 times)

vijay@spinetechnologies

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 82
    • View Profile
fetch colModel from server side
« on: January 03, 2022, 11:53:40 am »
I am using server-side pagination in the PQ grid. The column name will come dynamically from the server side as per my query string. I am fetching both the data and column from a single query. I am able to bind data to the grid but am not able to find any way to dynamically bind colModel to my grid. Please ref my code

//to get data from server side
var dataModel = {
        location: "remote",
        dataType: "JSON",
        method: "GET",
        url: stdFilterFetchData,
        getData: function (dataJSON) {
            var data = JSON.parse(dataJSON);
            // column data from server side in json format
            colModel = data.Data.model;
            return {
                curPage: dataJSON.curPage, totalRecords: dataJSON.totalRecords, data: data.Data.listData, colModel: data.Data.model };
        },
    };


//grid init
$('#tb_' + tableName).pqGrid({
            width: 800, height: 450,
            dataModel: model,
            colModel: colModel,
            freezeCols: 2,
            pageModel: {
                type: "remote",
                rPP: 20,
                strRpp: "{0}"
            },
            sortable: false,
            selectionModel: { swipe: false },
            wrap: false, hwrap: false,
            numberCell: { resizable: true, width: 30, title: "#" },
            title: "Shipping Orders",
            resizable: true,
            stringify: true
        });

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6124
    • View Profile
Re: fetch colModel from server side
« Reply #1 on: January 03, 2022, 05:14:14 pm »
refreshCM method is used to dynamically set colModel of the grid.

https://paramquery.com/pro/api#method-refreshCM