Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - cpopolo

Pages: [1]
1
Hi,

I would like to combine two aspects of existing examples:

So my question is, what are the general methods I should use to have a show/hide detail row under any existing detail row in the treeview?  In the treeview example, imagine a + or - sign to show/hide additional details under row 5 or 6.  In other words, at the "detail" level of the treeview, I would like to show additional details as an option.  The additional details should span across the entire with of the paramquery grid.  It might, for example, contain a PDF viewer of an actual bill related to the detail data of the row.

I'm pretty comfortable with the individual examples, I'm just not sure how or where to combine the different elements that would allow for one functionality (additional details) inside of the other (a treeview hierarchy which has details at the lowest level).

Thanks in advance.

P.S. - My profile is "Pro" but I was unable to post this in the Pro area because of an error reported by the forum script.  Can you check my account?


2
Help for ParamQuery Pro / Re: grid.Checkbox('name') not working
« on: March 03, 2020, 11:45:36 pm »
Below is the entire function to setup the grid based on a Data parameter which retrieves many rows from a PHP AJAX call.  I didn't see any documentation that describes checkboxes as "normal" (or not normal?).  So I cannot answer your question of whether I have set up a normal checkbox or not, so maybe you could explain that.  I've attached a picture of what the treegrid looks like.

Code: [Select]
function makepqgridnav_interval(data) {
   
    console.log("and what do we have here?",data.results)
   
    ///////// SHAPE DATA
    ///////// SHAPE DATA
    ///////// SHAPE DATA
    var pqdatanavimain = [];
    var ni=0;
    var pqdata2childrenimain = [], totcost=0, totusage=0;
    var pqmergeCells = [];
   
    $.each(data.results.meters, function(i,d) { // each METER
        oBoard = {
            'id': 'id' + d[0].board_id,
            'name': d[0].board_id + ' ' + d[0].board_sn,
            'meter': d[0].board_id + ' ' + d[0].board_sn,
            'address': d[0].board_id + ' ' + d[0].board_sn,
            'size': d.length,
            'date': moment(d[0].sensor_sample_data_dt).format("MMM DD, YYYY"),                       
            'children': null,
        };
        pqdata2childrenimain = [];
        $.each(d, function(i2,d2) {
           
            ni++;
            totusage += d2.lastdatavalue;
            pqdata2childrenimain.push({
                "id": "id" + d2.sensor_id,
                "name": d2.sensor_sn,
                'sensor': d2.sensor_id,
                "size": d2.sensor_sample_data + " " + htmlDecode(d2.unitabbrev),
                "date": moment(d2.sensor_sample_data_dt).format("MMM DD, YYYY"),
                'deviceid': d2.deviceid,
                'devicedesc': d2.devicedesc,
                'devicemetasensor': d2.devicemetasensor,
                'forecolor': d2.forecolor,
                'backcolor': d2.backcolor,
            });
        });
       
        ni++;
        pqdatanavimain.push({
    "id": oBoard.id,
            "name": oBoard.name,
            "meter": oBoard.meter,
            "size": oBoard.size,
            "date": oBoard.date,
            "children": pqdata2childrenimain,
        });
       
        pqmergeCells.push(
            {'r1': ni, 'c1': 1, 'rc': 1, 'cc': 99}
        );
       
    });

    console.log('data for pqgridnav-imain',pqdatanavimain);
    ///////// GRID MODEL
    ///////// GRID MODEL
    ///////// GRID MODEL
    var pqgroupModel = {
        on: true,
        dataIndx: ['name'],
        collapsed: [true,true,true],
        title: [
            "{0} ({1})",
            "{0} - {1}"
        ]
    };
       
    var pqobj = {
        selfOptions: {
            suppressText: "",
        },
        height: 800, // 'flex',
        maxHeight: 800,
        minHeight: 800,               
        resizable: true,
        filterModel: { on: true, mode: "AND", header: true },
swipeModel: { on: 'touch' },
        stripeRows: false,
        groupModel: pqgroupModel,
        rowInit: function(ui){
//var rd = ui.rowData, color = ["lightyellow","lightgreen","pink","lightblue"];
//if( rd.pq_gsummary ){
// return {style:"background:" + color[rd.pq_level] + ";"};
//}
},
        rowBorders: false,
        showToolbar: false,
        numberCell: false,
        showHeader: true,
        showTitle: false,
        showTop: false,
        width: '100%',
        rowHt: 12,
// removed toolbar
        treeModel: {
            dataIndx: 'name',           
            //select: true,           
            checkbox: function(rd){
                if (rd.hasOwnProperty('meter')) {
                    return false;
                } else {
                    return true;
                }                             
            },           
            checkboxHead: false,
            cascade: true,           
            icons: false,
            collapsed: true,
            render: function (ui) {
                //console.log('ui',ui)
                if (ui.rowData.hasOwnProperty('meter')) {
                    return {
                        text: "<span class='spanaddress trspan" + ui.rowData.meter + " row" + ui.rowData.id + "'>" + translate(ui.rowData.meter.replace(pqobj.selfOptions.suppressText,'')) + "</span>",
                        cls: 'checkmark meter meter' + ui.rowData.meter,
                        attr: 'data-one=' + ui.rowData.meter,
                    }
                };
                if (ui.rowData.hasOwnProperty('sensor')) {
                    return {
                        text: "<span class='spanmeter trspan" + ui.rowData.sensor + " row" + ui.rowData.id + "' title='" + ui.rowData.sensor + "'>" + translate(ui.cellData) + "</span>",
                        cls: 'checkmark meter meter' + ui.rowData.sensor,
                    }
                }
            },
summary: false, // otherwise blank row with summaries before each outdent
            style: {
                'font-size': '11px', 'color': '#555'
            },
        },
        sortModel: {ignoreCase: true},
        scrollModel: { autoFit: true },
        columnTemplate: {
            minWidth: '30%',
            maxWidth: '50%',
            width: '50%',
            style:
                {'font-size': '11px', 'color': 'black', 'line-height': '1em', 'font-family': 'Droid Sans'  },
            styleHead: {'font-size': '11px' },
        },
        menuIcon: false,
        editor: { style: 'font-size: 11px;' },
        mergeCells: pqmergeCells,
        colModel: [
            //optional column required only to implement disabled checkboxes.
            {
                height: '15px',
                dataIndx: 'pq_tree_cb',
                hidden: true,
                editable: false,
            },{
                dataIndx: 'name',
                hidden: false,
                width: '90%',
                maxWidth: '90%',
                minWidth: '90%',
                height: '15px',
                title: 'Meter / Sensor',
                exportRender: true,
                filter: {
                    crules:[{ condition: "contain" }]
                },
                style: { 'font-size': '11px', 'color': 'black', 'line-height': '1em', 'font-family': 'Droid Sans' },
                render: function (ui) {
                    //return ui.cellData + "<br/>" + ui.rowData.size + " (<span title='" + ui.rowData.devicemetasensor + "' style='color: " + ui.rowData.forecolor + "; background-color: " + ui.rowData.backcolor + ";'>" + ui.rowData.deviceid + "</span>)";
                },
                styleHead: {'font-size': '11px'},
                editable: false,
            },
//            {
//                cls: 'meter usagekwh',
//                dataIndx: 'size',
//                width: '28%',
//                maxWidth: '28%',
//                minWidth: '28%',
//                title: 'Typical Value',
//                hidden: false,
//                exportRender: true,
//                dataType: 'float',
//                format: "#,###",
//                filter: {
//                    //crules:[{ condition: "contain" }]
//                },
//                render: function (ui) {
//                    return ui.cellData + " (<span title='" + ui.rowData.devicemetasensor + "' style='color: " + ui.rowData.forecolor + "; background-color: " + ui.rowData.backcolor + ";'>" + ui.rowData.deviceid + "</span>)";
//                   
//                },
//                styleHead: {'font-size': '11px'},
//            },
//                    {
//                        cls: 'meter lastbill',
//                        dataIndx: 'date',
//                        title: 'Last Bill',
//                        dataType: 'date',
//                        style: {'font-size': '11px' },
//                        styleHead: {'font-size': '11px' },
//                    }
        ],
        beforeCheck: function (event,ui) {
//            var mycheckbox = ui.grid.Checkbox('name');
//            mycheckbox.unCheckAll();
            // UNCHECK ALL
            affected = thetreenavimain.getCheckedNodes();
            $.each(affected, function(di,dq) {
                //console.log('this.dq',dq)
                this.pq_tree_cb = false;
                this.pq_cellcls = {name: ''};
                //thegridnavimain.removeClass({rowIndx: dq.rowIndx, dataIndx: 'name', cls: 'selected' });                           
                //dq.updateRow({ newRow: {state: false}, rowIndx: ui.rowIndx });
            });
            thegridnavimain.refreshView();           
        },
        check: function( event, ui ) {
            var affected;
            if (typeof ui.getCascadeList === 'function') {
                affected = ui.getCascadeList();
                //console.log('affected',affected)
                $.each(affected, function(di,dq) {
                    //console.log(dq,dq.newRow.pq_tree_cb);
                    if (dq.newRow.pq_tree_cb==false) {
                        thegridnavimain.removeClass({rowIndx: dq.rowIndx, dataIndx: 'name', cls: 'selected' });                           
                    }
                    if (dq.newRow.pq_tree_cb==true) {
                        thegridnavimain.addClass({rowIndx: dq.rowIndx, dataIndx: 'name', cls: 'selected' });                           
                    }
                })
            } else {
                affected = ui.rows;
                console.log('affected',affected)
                $.each(affected, function(di,dq) {
                    //console.log(dq,dq.rowData.pq_tree_cb);
                    if (dq.rowData.pq_tree_cb==false) {
                        thegridnavimain.removeClass({rowIndx: dq.rowIndx, dataIndx: 'name', cls: 'selected' });                           
                    }
                    if (dq.rowData.pq_tree_cb==true) {
                        thegridnavimain.addClass({rowIndx: dq.rowIndx, dataIndx: 'name', cls: 'selected' });                           
                    }
                })
            }
            var qchecked = thetreenavimain.getCheckedNodes();
            var chtsensors = "", runtimetitle;
            $.each(qchecked, function(di,dq) {
                if (dq.hasOwnProperty('sensor')) {
                    chtsensors += (chtsensors>'' ? "," : "" )  + dq.sensor;
                    runtimetitle = dq.name + " (" + dq.sensor + ")";
                }
            });
            console.log('The selected Sensor(s):',qchecked);
            //makepqgriddata(data,qchecked);
           
            chartdef['profile1d'].chtsensorlist = chtsensors;
            chartdef['profile1d'].chartoptions.title.text = runtimetitle;
            chartProfiler('portlet-1d-scurve',chartdef['profile1d'], {}, (function(d,s) { doProfilerMarkup(d,s) }));           
           
        },
        dataModel: { data: pqdatanavimain }
    }
    thegridnavimain = pq.grid("#pq-tvnavigator-imain", pqobj);
    thetreenavimain = thegridnavimain.Tree();

    for (var i=0; i<pqdatanavimain.length; i++) {
        pqmergeCells.push(
            {'r1': pqdatanavimain[i]["pq_ri"], 'c1': 1, 'rc': 1, 'cc': 99}
        );
    };
    thegridnavimain.refreshView();           

};

3
Help for ParamQuery Pro / grid.Checkbox('name') not working
« on: March 03, 2020, 01:05:53 am »
I have an example straight from the documentation but cannot make it work.  The goal is to uncheck all checkboxes before letting the user check a new checkbox.  This is to insure only one row is selected before a chart is drawn.

Code: [Select]
var thegrid = pq.grid("#pq-tvnavigator-imain", pqobj);

Then, in the pqobj.beforeCheck I have the following function:

Code: [Select]
        beforeCheck: function (event,ui) {
            console.log('the beforeCheck');
            var Checkbox = thegrid.Checkbox('pq_tree_cb');
            Checkbox.unCheckAll();
        },

This event causes a console error:

buda-interval-pqgrid.js:211 Uncaught TypeError: Cannot read property 'unCheckAll' of undefined

I just downloaded version 7.1.0 of Paramquery Pro...

Please help!

4
I don't see what I should target from outside of the PQ grid to set a class on a row?  In my example, if user clicks on a bar in the Highcharts bar chart, what would the onclick code look like in the Highchart even that would trigger an addClass to a specific matching row in the grid?  Could you sketch a quick code snippet that might be called from jQuery to affect a row in the grid?

5
Hi,

Virtualization in the data grid is mostly a headache when a grid only has a few dozen or hundred rows - I would much rather that all rows are available for classing so that they hold their class after the row scrolls out of the viewport.  Similarly, I would like to class rows that may not yet be rendered and may scroll into view by user action.  Is there a way to turn off paging/virtualization and simply have all data available at all times?

Here's an example that illustrates my problem - and I'm open to a suggestion on how to make it work if virtualization cannot be turned off:

  • User may click a bar on the bar chart.  The corresponding row in the grid is classed with 'selected' and shows with an orange month/year
  • If the user scrolls up or down so that the selected row leaves the viewport, the class on the selected row is lost and the month/year is no longer orange if the user scrolls that row back into view.

Similarly, the user might select a bar in the chart that is not currently in the viewport.  I would like to add the 'selected' class to any DIV with the correct selector even if the DIV doesn't yet exist in the viewport.  jQuery handles this when the On Click events are set up properly, but I cannot seem to do the same thing in PQ.  If I create a list with getCellsByClass, only those in the current viewport are returned for example.  The list will not include future elements created with the same class...



Thanks in advance for your advice.

6
Brilliant, thanks...  My revised code is much more concise and no longer depends on beforeCheck event:

Code: [Select]
                check: function( event, ui ) {
                   
                    var affected = ui.getCascadeList();
                    $.each(affected, function(di,dq) {
                        console.log(dq,dq.newRow.pq_tree_cb);
                        if (dq.newRow.pq_tree_cb==false) {
                            thegridnav.removeClass({rowIndx: dq.rowIndx, dataIndx: 'name', cls: 'selected' });                           
                        }
                        if (dq.newRow.pq_tree_cb==true) {
                            thegridnav.addClass({rowIndx: dq.rowIndx, dataIndx: 'name', cls: 'selected' });                           
                        }
                    })
                   
                },


If there's an improvement for the above, please let me know...  My next step is to Update a parallel grid with the same structure.  If you have a quick tip on how to Refresh the dataModel.data, I'd appreciate it.  My current code has a problem when it is called a second time with a different dataset.

7
Thank you - I now have this working as intended, but I'd like to ask if the code example below is best practice.  Upon checking a box with children, I first clear the 'selected' class from all checkboxes in the 'beforeCheck' event and then addClass back in the 'check'event.  This is seems to be the only way to clear the class when a box (and it's children) are unchecked.  Does this make sense or is there a simpler way?

Here is the code:

Code: [Select]
                beforeCheck: function(evt,ui) {
                    $.each(thetreenav.getCheckedNodes(), function(di,dq) {
                        thegridnav.removeClass({rowIndx: dq.pq_ri, dataIndx: 'name', cls: 'selected' });                           
                    })
                },
                check: function( event, ui ) {
                    console.log('check',event,ui,thetreenav.getCheckedNodes());
                    $.each(thetreenav.getCheckedNodes(), function(di,dq) {
                        thegridnav.addClass({rowIndx: dq.pq_ri, dataIndx: 'name', cls: 'selected' });                           
                    })


Here is a screen shot of the menu showing that the checked boxes have a dark background on the text that goes with the checkbox.


8
Thanks... Can you point me to the correct piece of documentation that might describe how to add a class to an element in a row when it is checked?  And to include the children rows as well?  Example: If I check a checkbox for a parent in a tree grid, I want to change the background color of the name, as well as the background color of all the children.

9
Hi, I'm evaluating Pro and trying to integrate certain jQuery methods into a Tree grid.

I have the following 'check' event function:
Code: [Select]
               
check: function( event, ui ) {
                    console.log('complete',event,ui);
                    donavchecks();
                    //this.addClass({rowIndx: ui.rowIndx,cls: 'selected'});
                },

The "donavchecks()" call looks like this.  You'll have to trust that I have classed grid elements appropriately, and in fact if I call "donavchecks()" at the console prompt it works fine...

Code: [Select]
function donavchecks() {
   var q = thetreenav.getCheckedNodes();
   console.log(q);
   $('.spanmeter').removeClass('selected')
   $.each(q, function(qi,qd) {
      $('span.trspan' + qd.meter).addClass('selected');
   })
}                   

So it seems to me that the "cls" definitions of the grid might be overwriting any classes that I assign in the check event.  How do I operate on the grid after it is completely quiet after a check event?

Thanks in advance.


Pages: [1]