Author Topic: Formula option is not working  (Read 999 times)

vinay

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 1
    • View Profile
Formula option is not working
« on: August 26, 2021, 10:51:10 pm »
Dear Support,
I am using the grid version paramquery-8.1.0 that is download from your portal. it is working fine for hierachy and showing the hierarchy but i need to implement the formula so I could implement the login like Total = A+B, in case if I change the value of A or B then system should automatically change the total value. please find below the code and help me.

  var colM = [
            { title: "", minWidth: 27, maxWidth: 27, type: "detail", resizable: false, editable: false, sortable: false },
            { title: 'Team', dataIndx: 'name' },
            {
                title: "Allocated <br/> %age", width: 120, align: "center", dataType: "float", editable: true, formula: function (ui) {
                    var rd = ui.rowData;
                    return rd.JanTarget + rd.JanRevenue;
                }

            },
            { title: "Revenue <br> %age", width: 100, align: "center" },
            {
                title: "Jan", width: 120, align: "center", colModel: [{ title: "Target", width: 72, dataIndx: 'JanTarget', dataType: "float" }, { title: "Revenue", dataType: "float", width: 72, dataIndx: 'JanRevenue' }]},
            { title: 'Feb', width: 120, align: "center", colModel: [{ title: "Target", width: 72, dataIndx: 'FebTarget' }, { title: "Revenue", width: 72, dataIndx: 'FebRevenue' }] },
            { title: 'March', width: 120, align: "center", colModel: [{ title: "Target", width: 72, dataIndx: 'MarchTarget' }, { title: "Revenue", width: 72, dataIndx: 'MarchRevenue' }] },
            { title: 'Apr', width: 120, align: "center", colModel: [{ title: "Target", width: 72, dataIndx: 'AprTarget' }, { title: "Revenue", width: 72, dataIndx: 'AprRevenue' }] },
            { title: 'May', width: 120, align: "center", colModel: [{ title: "Target", width: 72, dataIndx: 'MayTarget' }, { title: "Revenue", width: 72, dataIndx: 'MayRevenue' }] },
            { title: 'June', width: 120, align: "center", colModel: [{ title: "Target", width: 72, dataIndx: 'JuneTarget' }, { title: "Revenue", width: 72, dataIndx: 'JuneRevenue' }] },
            { title: 'July', width: 100, align: "center", colModel: [{ title: "Target", width: 72, dataIndx: 'JulyTarget' }, { title: "Revenue", width: 72, dataIndx: 'JulyRevenue' }] },
            { title: 'Aug', width: 100, align: "center", colModel: [{ title: "Target", width: 72, dataIndx: 'AugTarget' }, { title: "Revenue", width: 72, dataIndx: 'AugRevenue' }] },
            { title: 'Sep', width: 100, align: "center", colModel: [{ title: "Target", width: 72, dataIndx: 'SepTarget' }, { title: "Revenue", width: 72, dataIndx: 'SepRevenue' }] },
            { title: 'Oct', width: 100, align: "center", colModel: [{ title: "Target", width: 72, dataIndx: 'OctTarget' }, { title: "Revenue", width: 72, dataIndx: 'OctRevenue' }] },
            { title: 'Nov', width: 100, align: "center", colModel: [{ title: "Target", width: 72, dataIndx: 'NovTarget' }, { title: "Revenue", width: 72, dataIndx: 'NovRevenue' }] },
            { title: 'Dec', width: 100, align: "center", colModel: [{ title: "Target", width: 72, dataIndx: 'DecTarget' }, { title: "Revenue", width: 72, dataIndx: 'DecRevenue' }] }
        ];
     /*   $(".selector").pqGrid({ colModel: colM, dataModel: { data: data } });*/
        //initialize main grid
        $("#grid_md").pqGrid({             
            height: 'flex',
            width: 1700,
            maxHeight: 700,
           
            dataModel: { data: data },           
            scrollModel: {autoFit: true, flexContent: true},
            colModel: colM ,
            numberCell: { show: false },
            title: "<b>Division Teams</b>",
            resizable: true,           
            detailModel: {
                init: function (ui) {
                   
                    var rowData = ui.rowData,
                        model = subContinentModel( rowData.data ),
                        $grid = $("<div></div>").pqGrid(model);

                    return $grid;
                }
            }
           
           
        });

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Formula option is not working
« Reply #1 on: August 27, 2021, 10:41:33 am »
formula API is different in free and Pro version 8.1.0

Please check this example: https://paramquery.com/pro/demos/grid_formula

and API: https://paramquery.com/pro/api#option-formulas