Author Topic: Refreshing columns and data  (Read 4145 times)

joaosales

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 20
    • View Profile
Refreshing columns and data
« on: January 12, 2018, 06:32:00 pm »
Hi, I have a grid that shows data for some items during the a year and a text field and 2 buttons to change the years like the attachment.

When i either click one of the buttons or type the year it will refresh the table data and columns to reflect the chosen year.
But the way i'm doing it it is updating the colModel, but the columns are not being updated and so the groupheader of the grid still showing the year that is loaded, am i missing something?
Here is the code for the table update of the colModel, the buildColumnModel method only creates a new array setting a new parent named after the new year and the 12 columns for each month.

Code: [Select]
var $filterText = this.toolbar().find(".filterValue"),
                            oldVal = Number($filterText.val());           
                        $filterText.val(--oldVal);
                        let date = new moment().year(oldVal);
                        date = date.startOf('year');
                        this.colModel = buildColumnModel(date, true);
                        this.option( 'colModel', grid.option( 'colModel') );
                        this.refresh();

Thanks,

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Refreshing columns and data
« Reply #1 on: January 12, 2018, 10:39:21 pm »
you can't assign colModel to grid like this.

this.colModel = buildColumnModel(date, true); it is incorrect.

Assuming you want to update whole colModel with buildColumnModel(date, true)

Code: [Select]
this.refreshCM( buildColumnModel(date, true) );
this.refresh();

joaosales

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Refreshing columns and data
« Reply #2 on: February 19, 2018, 10:22:11 pm »
Hi, im with a problem related to what i was doing here
I fixed to use the refreshCM and it worked like planned. But I have now a checkbox column mapped to true/false values
Code: [Select]
{
                title: "Total",
                dataIndx: "sumRow",
                type: 'checkbox', //required property.
            }

and every time i use the buttons that refresh the colModel the column stops being a checkbox and only show true and false values.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Refreshing columns and data
« Reply #3 on: February 20, 2018, 10:56:38 am »
Checkbox column can't be added or removed dynamically, it should be predefined in the initial colModel.

It can only be hidden/ made visible after initialization.

If you are still facing issues, please share a jsfiddle/ plnkr.

Digitalsoft

  • Pro OEM
  • Newbie
  • *
  • Posts: 49
    • View Profile
Re: Refreshing columns and data
« Reply #4 on: March 11, 2021, 06:30:58 pm »
Is the above issue fixed or it is still an open issue in PQ grid, We are having a similar requirement like this

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Refreshing columns and data
« Reply #5 on: March 11, 2021, 06:46:52 pm »
Checkbox column can be added or removed dynamically in recent version.