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 - MEngelbyPQ

Pages: [1] 2
1
Help for ParamQuery Pro / classes for pq_summary rows
« on: March 05, 2020, 01:28:13 am »
I'm using PQ7.1 and want to style the summary rows when the group changes. Here is the code for the groupModel:
Code: [Select]
                groupModel: {
                    on: true, header: false,
                    dataIndx: ['siteabbr'], title: ["{0}"],
                    showSummary: [true],
                },
When I look at the DOM there are no classes identifying the summary rows.  The documentation says grouping adds properties to the rows of pq_gtitle, pq_gsummary, pq_grandsummary, pq_level, pq_close but I don't see how I can use that for CSS styles if those names don't show up in the DOM.

What is the preferred way to style summary rows in the grid given the latest version 7.1.0?

Figured it out.
Code: [Select]
                rowInit: function(ui) {
                    if (ui.rowData.hasOwnProperty('pq_gsummary') == true) {
                        return { cls: 'pq_summary' };
                    }
                },

2
Well, not exactly fail.  It causes Excel to complain about something (it won't say) and by pressing ok on the dialog warning, the worksheet will load.  But for unknowing users, this is very concerning.  When the grid title is too long, and exportData is invoked, the warning that shows up is:
"We found a problem with some content in '{workbook name}.xlsx'. Do you want us to try to recover as much as we can? if you trust the source of the workbook, click Yes."

The PSA is: keep your Grid Titles less than 31 characters or specify the 'sheetName' option in the exportData method.

Ps.  It took me an embarrassingly long amount of time to figure this out.

3
I like that method better.  Why I didn't think of it when defining the detailModel is a bit confusing to me now.  But it makes more sense being there.  Thank you for the insight.

4
It took me a while to figure this out and this is the solution I came up with.  Using code from this thread, I added to the init function for detailGrid:
Code: [Select]
detailModel: {
    init: function (ui) {
        var rowData = ui.rowData,
            model = binDetailModel( $(this).pqGrid('instance'), rowData ),
            $grid = $("<div class='hourDetail' />").pqGrid(model);

        //save reference to rowData in detail grid.
        $grid.data( 'rowData' , rowData);

        return $grid;
    }
}
But I was finding difficulty getting the instance of the detailGrid in the render function.  This is what I settled on:
Code: [Select]
var detailRender = function(ui) {
    var cellContents = {}, cellStyle = '';
    var cellData = parseFloat(ui.cellData);
    // Get the div for this detailGrid
    var $grid = $(this.element).closest( 'div' );
    var rowData = $grid.data('rowData');

    // Logic to change the class based on values in the rowData

    return cellContents;
}

Is this code robust enough to always return the proper detailGrid in $grid or will it return the next following grid when the render function is executed during the last rows of the detailGrid?
Or is there a better way to get the detailGrid from the render callback function when invoked in colModel render?

5
Help for ParamQuery Pro / Re: prevent a detailgrid from opening?
« on: September 21, 2018, 06:44:41 pm »
Many thanks.  I was able to add it during initialization with:
Code: [Select]
$('#selector').pqGrid({beforeRowExpand: function(evt, ui) {
    if (ui.rowData.lastread == 'NOT CURRENT') {
        return false;
    }
    return true;
}});

6
Help for ParamQuery Pro / prevent a detailgrid from opening?
« on: September 21, 2018, 12:11:10 am »
I have grid where the column Model has a detail column.  Is there a way to prevent the detailGrid from expanding when the detail icon is clicked on in the row?
Based on the rowData I have logic that determines if the detailGrid will be valid or not and I'm wondering if there is a way to to prevent the grid from opening when there is no data to show for the detail?

7
Thanks for the insight ParamQuery.

While not exactly what I was hoping for, your answers do show that I am trying to use the flex resizing feature not as designed.
I'll need to rethink what I am trying to accomplish and adjust as needed.

8
Plunker link: https://plnkr.co/edit/Ciykx8LuUs9TH0Uzq1C7?p=preview

This is what I am attempting:
  • Grid Title to be completely shown when resizing grid.  Currently, because the cell content widths are too small, the grid title is clipped.
  • When a detail cell is clicked, resize the main grid to show all of the detail grid, Currently, the detail grid cell contents widths are larger than the main grid, thus clipping the detail grid.
  • The row height should be the height of the detail grid.  Not sure why this is happening, in my other code base the containing row sizes to the same height as the detail grid.
For point 2, the complete function is an attempt to figure out the widths and resize the main grid.   The logic in that function would work better in an event that fired after the row is expanded.  There is an event 'beforeRowExpand' but that won't work for what I am trying to do.  I am using PQpro 4.0.2 but as you can see, the latest version shows the same behavior.

Is there a way to programmatically resize the main grid width so all the detail grid can be seen?

-Mike

9
Help for ParamQuery Pro / Re: Get the collapsed state of a group?
« on: May 05, 2018, 12:58:20 am »
Many thanks!  The answer seems obvious once it has been pointed out and I know where in the documentation to look.  But for whatever reason, my mind wasn't figuring out how to read options for the groupModel.

Is there a way to contribute to the documentation?  This may be helpful to add to the groupModel code examples section.
From:
Code: [Select]
Get or set the groupModel option, after initialization:

//getter
var groupModel = grid.option( "groupModel" );
 
//setter
//group by ShipCountry and keep it collapsed.
grid.Group()option({
    dataIndx: ['ShipCountry'],
    collapsed: [ true ]
});

To:
Code: [Select]
Get or set the groupModel option, after initialization:

//getter
var groupModel = grid.option( "groupModel" );
 
//setter
//group by ShipCountry and keep it collapsed.
grid.Group().option({
    dataIndx: ['ShipCountry'],
    collapsed: [ true ]
});

// Toggle the collapsed state of a group
// by JSON dataIndx
grid.Group().option({
    collapsed: [ !this.option('groupModel.collapsed')[
        this.option('groupModel.dataIndx').indexOf('ShipCountry')
    ] ]
});

// by Array Index
grid.Group().option({
    collapsed: [!this.option('groupModel.collapsed')[0]]
});

10
Help for ParamQuery Pro / Get the collapsed state of a group?
« on: May 04, 2018, 03:00:02 am »
Is there a way to retrieve the collapsed state of a group from within a toolbar item listener function?  I have only 1 group and this is what I came up with, but it is pretty janky.  All the commented out lines are things that I've tried.
Code: [Select]
                        {
                            type:'button',
                            label: 'Toggle Sites',
                            listener: function() {
                                //var $siteGrpOpts = this.groupOption('collapsed');
                                var $site = this.Group();
                                 window.siteCollapsed = !window.siteCollapsed;
                                 if (window.siteCollapsed) {
                                    $site.collapse();
                                 } else {
                                    $site.expand();
                                 }
                                //var $siteState = this.option('groupModel.collapsed[0]');
                                //var $siteState1 = $site.option.collapsed;
                                //var $siteState2 = $site.groupOption('collapsed');
                                //this.groupOption('collapsed', !$siteState1);
                            }
                        },

11
Thanks for the suggestion mgregory85.  That was one of my attempted fixes.  It works well until one uses the filtering option.  There doesn't seem to be a way to identify rows that are filtered out.

That's what I needed ParamQuery.  Thank you.
Took me a bit to figure out how to get the grand summary row to look like it was previously.
I added a rowInit conditional to check for the key 'pq_grandsummary' and changed the content of the company cell.

Here is my latest iteration;  https://plnkr.co/edit/9I7q9uJwnbnFTQdZ090W?p=preview

12
Help for ParamQuery Pro / Grand Summary adding in Group summaries
« on: May 02, 2018, 01:07:23 am »
Greetings!

I've run into something that I can't figure out how to correct.

Given this grid, https://plnkr.co/edit/CmjcHCV4OcSftwV2mqu5?p=preview, grouping has been turned on with summaries being shown at the bottom of the group.
While the group summaries are correct, the Grand Summary in the last row appears to add the group summary total twice.  The effect seen is the group detail lines are totaled then multiplied by 3.
If a person comments out the summary options in the colModel (script.js lines 32, 35, and 40), the Grand Summary computes correctly.

In the summaryData option, is there a way to alter the summing function 'sum(C:C), etc' to ignore the group summing rows?

-Mike

13
Help for ParamQuery Pro / Re: export HTML background color for cells
« on: January 25, 2017, 07:55:05 pm »
Understood.

Hopefully when using the exportData function a boolean var will enable column.render and rowInit functions in HTML output and that won't impact performance too much for either case.  Thanks for the consideration.

14
Help for ParamQuery Pro / Re: export HTML background color for cells
« on: January 25, 2017, 04:32:31 am »
Thanks for cssRules!  That works great!

-BUT-
How do I add a class to a cell in the export Html?  I've tried in the column.render function with the conditional ui.Export.  When I examine the output file the class isn't there.  I've looked at the documentation for rowInit and I can't figure out how to add a class to cells in that function.  if I add a class to the row, that class doesn't show up in the exported html file.

I am using the latest 3.3.5 version.

15
Help for ParamQuery Pro / Re: export HTML background color for cells
« on: January 24, 2017, 03:46:43 am »
I sort of found a solution.  Add a container div surrounding the ui.cellData with the css height set to 100%.

Code: [Select]
render: function(ui) {
    if (ui.Export) {
        return { text: "<div style='height:100%;overflow:hidden;background:#ffff99;'>" + ui.cellData + "</div>" };
    }
}

The issue then becomes that the <th> and <td> tags are styled with 5 pixel padding in the htm export file which forces a white background around the cell contents.

Suggestion:
Add a method for export to either override or add to the inline style code in the html export file.  With that, it becomes quite simple to add styling for any rows/cells/groups/etc by adding a class and then styling that class in the inline style code.

Pages: [1] 2