Recent Posts

Pages: 1 ... 4 5 [6] 7 8 ... 10
51
Bug Report / Re: New row comit and pq_detail column
« Last post by MichalV on March 25, 2025, 03:18:03 pm »
Because my grid uses Row details with tabs, based on your demo in "Nesting / Row details"
52
Help for ParamQuery Pro / Re: Export in 10.1.0
« Last post by queensgambit9 on March 24, 2025, 02:52:59 pm »
Solved.
53
Help for ParamQuery Pro / Export in 10.1.0
« Last post by queensgambit9 on March 24, 2025, 01:33:57 pm »
Hi

After loading a state and doing an export hidden columns seems to be exported aswell. How can I prevent this from happening?
54
refresh() is required after refreshCM() to see the new colModel in view.

PS: There are inbuilt options to control the save and load state properties.

https://paramquery.com/pro/api#option-stateColKeys

https://paramquery.com/pro/api#option-stateKeys
55
Hello,

I have implemented custom functions to save and load only the column order (order), visibility (hidden), and width (width). Below are my simplified customSaveState and customLoadState functions:

My question is: After setting the new colModel, is calling only grid.refreshCM() (Only:order, width, hidden properties) sufficient to apply these changes? Or should I also call grid.refresh() or another method?

I load this layout in the "create" command like this:
Code: [Select]
        create: function () {
            //this.loadState({ refresh: false })
            customLoadState(this, "isim1");
        },


Code: [Select]
function customSaveState(grid, key) {
    function simplifyColModel(colModel) {
        return colModel.map(col => {
            const simplified = {
                dataIndx: col.dataIndx
            };
            if (col.width != null) simplified.width = col.width;
            if (col.hidden != null) simplified.hidden = col.hidden;
            if (col.colModel) simplified.colModel = simplifyColModel(col.colModel);
            return simplified;
        });
    }

    const simpleState = simplifyColModel(grid.option("colModel"));
const state=JSON.stringify(simpleState);
    localStorage.setItem(key, state);
    console.log("Custom state saved to localStorage under key:", key);
}


function customLoadState(grid, key) {
    const saved = localStorage.getItem(key);
    if (!saved) {
        console.warn("No saved state found for key:", key);
        return;
    }

function reorderAndMerge(savedModel = [], originalModel = []) {
        const originalMap = {};
        originalModel.forEach(orig => {
            originalMap[orig.dataIndx] = orig;
        });

        const handled = new Set();
        const result = [];

        // savedModel
        for (const saved of savedModel) {
            const orig = originalMap[saved.dataIndx];
            if (!orig) continue;

            const merged = { ...orig };

            if (saved.width != null) merged.width = saved.width;
            if (saved.hidden != null) merged.hidden = saved.hidden;

            // nested colModel
            if (saved.colModel && orig.colModel) {
                merged.colModel = reorderAndMerge(saved.colModel, orig.colModel);
            }

            result.push(merged);
            handled.add(saved.dataIndx);
        }

        // savedModel newColumn
        for (const orig of originalModel) {
            if (handled.has(orig.dataIndx)) continue;

            const merged = { ...orig };

            if (orig.colModel) {
                merged.colModel = reorderAndMerge([], orig.colModel);
            }

            result.push(merged);
        }

        return result;
    }


    const savedCols = JSON.parse(localStorage.getItem("isim1") || "[]");
    const currentCols = grid.option("colModel");
    const updated = reorderAndMerge(savedCols, currentCols);
    console.log(currentCols);
    grid.option("colModel", updated);
    grid.refreshCM();
    //grid.refresh();
    console.log("Custom state loaded from localStorage:", key);
}
56
Help for ParamQuery Pro / Re: Pivot Grid - Default Aggregate function for Columns
« Last post by mlipham on March 21, 2025, 08:08:19 pm »
Awesome - thanks!
I'll keep my eyes peeled for the new version.
57
Bug Report / Re: New row comit and pq_detail column
« Last post by paramvir on March 21, 2025, 11:46:01 am »
I don't understand why you have added pq_detail in the colModel. Can you please clarify?
58
Help for ParamQuery Pro / Re: Using loadState in grouped fields
« Last post by paramvir on March 20, 2025, 06:10:22 pm »
Thanks for mentioning the steps.

Please add this patch to fix the error.

Code: [Select]
jQuery.paramquery.pqGrid.prototype.loadState=function(e){e=e||{};var t,o=this,r=$.widget.extend,d=e.state||o.getState();if(!d)return!1;pq.isStr(d)&&(d=JSON.parse(d));var a,l=d.colModel,i="pid"+Math.random(),n={},s={},p={},h=o.options,M=e=>e.dataIndx||e.id||e.title,c=(delete(a=h.stateColKeys).colModel,delete a.dataIndx,a),f=h.colModel,u=(e,t,o,r)=>{var d=o[t]={};e.forEach(((e,a)=>{var l=M(e);e.parentId=t,r[l]=e,d[l]=a,e.colModel&&u(e.colModel,l,o,r)}))};for(var g in u(l,i,s,n),p[i]={colModel:f},u(f,i,{},p),p){var v=n[g],N=p[g];if(v){if(N.parentId!=v.parentId){var w=p[N.parentId],I=p[v.parentId];I&&(w.colModel.splice(w.colModel.indexOf(N),1),I.colModel.push(N))}o._saveState(v,N,c)}}return function e(t,o){var r=s[o];r&&t.sort((function(e,t){return r[M(e)]-r[M(t)]})),t.forEach((t=>{delete t.parentId;var o=t.colModel||[];o.length&&e(o,M(t))}))}(f,i),o.iCols.init(),r(h.sortModel,d.sortModel),r(h.pageModel,d.pageModel),o.Group().option(d.groupModel,!1),o.Tree().option(d.treeModel,!1),t={freezeRows:d.freezeRows,freezeCols:d.freezeCols},isNaN(1*h.height)||isNaN(1*d.height)||(t.height=d.height),isNaN(1*h.width)||isNaN(1*d.width)||(t.width=d.width),o.option(t),!1!==e.refresh&&o.refreshDataAndView(),!0};

and ensure to use v10.x of pqgrid since support for grouped columns in state is not available in older versions.
59
Help for ParamQuery Pro / Re: Pivot Grid - Default Aggregate function for Columns
« Last post by paramvir on March 20, 2025, 12:37:59 pm »
I understand that's incorrect behavior of pqgrid pivot to use default aggregate as "sum" for all columns. It would be fixed in upcoming version.

Meanwhile please use this patch to fix it

Code: [Select]
jQuery.paramquery.cToolPanel.prototype.getObj=function(t){var a={},e=this.that;return t.find(".pq-pivot-col").each((function(t,r){var u=r.dataset.di,o=e.getColumn({dataIndx:u}),n=r.getAttribute("type")||o.summaryDefault||e.iGroup.getAggOptions(o.dataType)[0];o.summaryDefault=a[u]=n})),a};

you may remove the custom code in pivotCM event related to it.
60
you have to make few code changes in order to make it work for evaluation copy.

Please refer to the upgrade guides https://paramquery.com/pro/upgrade/Index to find out the required changes in your code.
Pages: 1 ... 4 5 [6] 7 8 ... 10