Author Topic: How to change the postdata and reload data  (Read 1911 times)

choidongjun

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 3
  • innodale
    • View Profile
How to change the postdata and reload data
« on: March 31, 2020, 11:01:41 am »
Hi,
I want to use postdata dynamically using a check button or input box.
How to change the postdata and reload data?

Code: [Select]
    $(function () {
        var colModel= [
            { title: "Product ID", dataType: "integer", dataIndx: "ProductID", editable: false, width: 80 },
            { title: "Product Name", width: 165, dataType: "string", dataIndx: "ProductName" },
            { title: "Quantity Per Unit", width: 140, dataType: "string", align: "right", dataIndx: "QuantityPerUnit" },
            { title: "Unit Price", width: 100, dataType: "float", align: "right", dataIndx: "UnitPrice" },               
            { title: "Units In Stock", width: 100, dataType: "integer", align: "right", dataIndx: "UnitsInStock" },
            { title: "Discontinued", width: 100, dataType: "bool", align: "center", dataIndx: "Discontinued" }
        ];

        var postData = {gridId:23, table: "products"};

        var dataModel = {
            location: "remote",
            dataType: "json",
            method: "GET",
            url: "/pro/products/get_jsonp",
            postData: postData,
            getData: function (dataJSON) {
                return {data: dataJSON.data};
            }
        };

        $("#grid_jsonp").pqGrid({
            height: 450,
            scrollModel: {autoFit: true},
            dataModel: dataModel,
            colModel: colModel,                                                           
            numberCell: { resizable: true, width: 30, title: "#" },
            title: "Products",
            resizable: true
        });
    });

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: How to change the postdata and reload data
« Reply #1 on: March 31, 2020, 02:01:16 pm »
postData can be implemented as a callback function in which you can check value of check button and input box and return value dynamically.

https://paramquery.com/pro/api#option-dataModel-postData

Data can be reloaded through call to refreshDataAndView() method.

https://paramquery.com/pro/api#method-refreshDataAndView
« Last Edit: March 31, 2020, 02:02:52 pm by paramvir »