Author Topic: Pivoted grid fails refresh  (Read 2648 times)

kadyrsizov

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 8
    • View Profile
Pivoted grid fails refresh
« on: August 30, 2019, 12:53:15 pm »
Hi there

I've implemented grid which uses rows and cols grouping (pivot mode) with remote data model. When I call refreshDataAndView method grid's view doesn't render updated data and displays empty view

Example:
http://jsfiddle.net/kL0gbav9/12/
Just press RefreshDataAndView button

What is the correct way to refresh data and view in the pivot mode?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Pivoted grid fails refresh
« Reply #1 on: August 30, 2019, 04:50:47 pm »
Thanks for sharing jsfiddle.

Turn off pivoting before refreshDataAndView()

Code: [Select]
listener: function (evt) {
     this.Group().option({on:false, pivot: false})
     this.refreshDataAndView();                           
}

and recreate pivot in complete event

Code: [Select]
complete: function(){
       this.Group().option({pivot: true, on: true})
},

https://jsfiddle.net/4eakqptm/

kadyrsizov

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Pivoted grid fails refresh
« Reply #2 on: August 30, 2019, 06:23:24 pm »
Thanks for the solution!

In my implementation user has ability to switch between pivot mode and not pivot mode dynamically and I can't enable pivot mode every time when complete event fires. Now I have to use some flag to manage this situation.
Is it possible implement this feature into the grid's core in next versions?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Pivoted grid fails refresh
« Reply #3 on: August 30, 2019, 07:20:00 pm »
No need to use a global flag. complete event handler can be written inside the listener itself.

Code: [Select]
listener: function (evt) {
                var on = this.option('groupModel.on'),
                            pivot = this.option('groupModel.pivot');

                this.Group().option({pivot: false, on: false})
                        this.refreshDataAndView();               

                        this.one('complete', function(){
                            this.Group().option({pivot: pivot, on: on})
                        })
}


https://jsfiddle.net/9bon57we/

kadyrsizov

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Pivoted grid fails refresh
« Reply #4 on: August 30, 2019, 09:35:31 pm »
Good idea! Thanks