Grid sort doesn't update after updateFromXML

I have a form which adds a record to the database, I then reload the XML with updateFromXML which works fine except I can’t seem to get the grid to resort, the new record is always added to the bottom of the grid. If I page refresh then it’s sorted properly.



–GRID CODE–



mygrid = new dhtmlXGridObject(‘mygrid_container’);

mygrid.setImagePath("/dhtmlx/dhtmlxGrid/codebase/imgs/");

mygrid.setHeader(“Date, Category, Description, Points”);

mygrid.setColSorting(“date,str,str,int”);

mygrid.setInitWidths(“80px,100px,140px,60px”);

mygrid.setColTypes(“ro,ro,ro,ro”);

mygrid.setColAlign(“center,center,center,center”);

mygrid.init();

mygrid.setSkin(“light”);

mygrid.load("/xml/members_data.php");





–POST FORM DATA CODE–



    $(document).ready(function(){

        $(“form#earnedspent_request”).submit(function() {

            var memberPoint_id= c3.getSelectedValue();

            $.ajax({

                url: “/submit/register.php?memberPoint_id=”+memberPoint_id,

                success: function(){

                    mygrid.updateFromXML("/xml/members_data.php", true, true);

                    mygrid.sortRows(0,“date”,“des”);

                }

            });

            return false;

        });

    });



Any pointers in the right direction would be most appreciated.





Updating is async. process , so to call sorting after data loading you need to have


mygrid.updateFromXML("/xml/members_data.php", true, true, function(){
mygrid.sortRows(0,“date”,“des”);
});

Worked perfectly.  Thanks.

So, is it possible to do this and maintain your current highlight and place in the page? We seem to lose the highlight on sort.

Thanks

If you are using updateFromXML or client side sorting - current selection will be preserved.
If you are fully reloading grid ( server side sorting scenarion ) - selection will be lost.