Get KoolPHP UI with 30% OFF!

Refreshing From AdvancedArrayDataSource

CASC
I have a page which contains a grid with an AdvancedArrayDataSource as a data source. The array being used is a $_SESSION array which is multidimensional.
When the user clicks a button on the page, a javascript is called which adds a new element to the array.
The grid is contained in an <updatepanel> and after the array element has been added the updatepanel is updated.
I have in the updatepanel a thing called Krumo which is a fancy formatted print_r - it displays the array with the newly added element.
The grid however does not show the added element until the refresh button on the grid is clicked at which point the grid catches up to the data in the $_SESSION array.
My question is - how do I get the grid to reload the array programatically with Ajax so the grid reflects the current state of the underlying array?
The updatepanel contains
<?php echo KoolScripting::Start(); ?>	
    <updatepanel id="second_updatepanel">
      <content>
        <![CDATA[
        <div style="min-height:100px;padding-top:10px;">
          <?php
          
          $grid_apps->refresh();          
          echo $grid_apps->Render();
          if ($_SESSION['authAdmin']) {
            krumo($_SESSION);
          }
          ?>
        </div>       
        ]]>												
      </content>
      <loading image="<?php echo $KoolControlsFolder; ?>/KoolAjax/loading/5.gif" />
    </updatepanel>
    <?php echo KoolScripting::End(); ?>
Posted Mar 27, 2016 Kool
Anthony Amolochitis
I have already done this.
Here is a link to my code sample I posted.
http://www.koolphp.net/forum/threads/130.1/using-the-advanced-array-datasource-and-refreshing-your-table-on-insert.html
I also posted a bunch of other code samples too.
http://www.koolphp.net/forum/21.1/code-examples.html
Hope this helps.
Posted Mar 28, 2016 Kool
CASC
I reviewed all those code samples, and particularly the one in http://www.koolphp.net/forum/threads/130.1/using-the-advanced-array-datasource-and-refreshing-your-table-on-insert.html.
It was helpful, but there is an issue with that particular sample in my case. The addition of the rows to the array datasource are not being done through the grid.
The array is a $_SESSION array and the elements are being added through a javascript function which calls a PHP script using an XMLHttpRequest which amends the array. Then the javascript calls second_updatepanel.update();
In that updatepanel I need to have commands which will cause the grid to refresh itself from the new array contents.
If I put a http://krumo.sourceforge.net/ call in the updatepanel, then the updated contents of the array are displayed by Krumo.
If I click the Refresh button on the grid, the correct array contents are displayed.
That's what I need to do, to get whatever happens when you click the Refresh button to happen in code.
Posted Mar 28, 2016 , edited Mar 28, 2016 Kool
Anthony Amolochitis
After successful insert of data, then execute the two javascript methods on the grid.
gridname.commit();
gridname.refresh();
That will automatically refresh the grid via javascript.
Posted Mar 28, 2016 Kool
CASC
gridname.refresh(); does the trick!
I don't need the commit because editing isn't being done in the grid yet. Of course, I think I am going to add functionality to allow the user to edit the array values in the grid, so I suspect I'll need that too.
Thanks!
Posted Mar 28, 2016 Kool -