Author Topic: Show differnet pqGrid in same div  (Read 3220 times)

hkosmidi

  • Pro Economy
  • Newbie
  • *
  • Posts: 4
    • View Profile
Show differnet pqGrid in same div
« on: May 06, 2015, 01:47:19 pm »
I have a question which I thought it was easy, but it seems I am missing something.

I have two buttons which load different type of data. I want to use the same div for output and the grid to be overwritten. The js code is:
Code: [Select]
$('#btnSubmit').on('click', function () {
            gridType = gridType || 'daily';

            if (grid != null && gridType == 'daily')
                $("#detailsGrid").pqGrid("refreshDataAndView");
            else
                grid = $("#detailsGrid").pqGrid(detailsGrid);
            //
            gridType = 'daily';
        });

        $('#btnSubmitMonthly').on('click', function () {
            gridType = gridType || 'monthly';

            if (grid != null && gridType == 'monthly')
                $("#detailsGrid").pqGrid("refreshDataAndView");
            else {
                if (grid != null)
                    $("#detailsGrid").pqGrid("destroy");
                //
                grid = $("#detailsGrid").pqGrid(monthlyDetailsGrid);
            }
            //
            gridType =


The error is:
Uncaught Error: cannot call methods on resizable prior to initialization; attempted to call method 'option'

It seems a jquery error but it is produced when the following code occurs:
Code: [Select]
$("#detailsGrid").pqGrid("destroy");
grid = $("#detailsGrid").pqGrid(monthlyDetailsGrid);

what is the error?
thanks

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6282
    • View Profile
Re: Show differnet pqGrid in same div
« Reply #1 on: May 06, 2015, 02:13:36 pm »
It is a common jQueryUI error that is thrown when a method is called on a widget before its initialization. Error in your case states that it happens on resizable widget. resizable widget is used to resize the grid.

Please share a jsfiddle demonstrating that error if you want me to investigate the cause of error.

hkosmidi

  • Pro Economy
  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Show differnet pqGrid in same div
« Reply #2 on: May 06, 2015, 03:41:03 pm »
It's quite difficult to reproduce a jsfiddle, so can you tell me which is the prefered methid to do such a thing?

wmwa

  • Pro Economy
  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: Show differnet pqGrid in same div
« Reply #3 on: May 06, 2015, 07:53:07 pm »
If your "destroy" code fires off before you ever actually create a grid, you will get that error.
I had a situation similar to this, and all I did was set a flag in the code to true that the grid was created. Then the function would check for that flag and only issue the destroy if it was already there. It's kind of a hacky fix, but it works.