Author Topic: How to refreshRow in detail grid  (Read 3430 times)

rallesaid

  • Newbie
  • *
  • Posts: 16
    • View Profile
How to refreshRow in detail grid
« on: July 28, 2016, 03:09:04 am »
I have a grid with continents and the detail with countries , if I add a new continent, the method refreshRow work fine to show the new ID, but if I add a country , does not work the method refreshRow and I can not show the new ID until recharge full page.

How I can refresh the grid detail ?

rallesaid

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: How to refreshRow in detail grid
« Reply #1 on: July 29, 2016, 12:57:26 am »
I'm using the autosave example     
http://paramquery.com/pro/demos/editing_instant

and the nested grid example
http://paramquery.com/pro/demos/nesting

the nested grid have the same toolbar that the parent grid.

My saveChanges function:
function guardar_cambios(grid) {
    //attempt to save editing cell.
    if (grid.saveEditCell() === false) {
        return false;
    }
   
    //if ( grid.isDirty() && grid.isValidChange({ focusInvalid: true }).valid ) {
    if (!$.active && !grid.getEditCell().$cell && grid.isDirty() && grid.isValidChange({ allowInvalid: true }).valid) {   
       
        var cambios = grid.getChanges({ format: "byVal"});
        var pathName = window.location.pathname;
        var recIndx = grid.options.dataModel.recIndx;
       
        var url = pathName + '/guardar_cambios';
        if(grid.options.sufijo){
            url = url + grid.options.sufijo;
        }
        //console.log(cambios);
        $.ajax({
            dataType: "JSON",
            type: "GET",
            async: true, 
            context: grid,         
            url: url,                           
            data: { listas: JSON.stringify(cambios) },           
            beforeSend: function (jqXHR, settings) {
                grid.showLoading();
            },
            success: function (cambios) {
                grid.commit({ type: 'add'});
                grid.commit({ type: 'update'});
                grid.commit({ type: 'delete'});
               
                //grid.refreshDataAndView();               
             },
            complete: function (cambios) {
                grid.commit();
                grid.hideLoading();
                grid.refreshDataAndView();
            },
        });
    }
}

i tried use a loop like a for, to iterate all the rows in the grid, and can use refreshRow({rowIndx: i }), but not working, also i tried use updateRow, whith the same result.


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6210
    • View Profile
Re: How to refreshRow in detail grid
« Reply #2 on: July 29, 2016, 05:04:48 pm »
Quote
I have a grid with continents and the detail with countries , if I add a new continent, the method refreshRow work fine to show the new ID, but if I add a country , does not work the method refreshRow and I can not show the new ID until recharge full page.

You need not call refreshRow method to display id of new rows as it's taken care of by commit() method.
http://paramquery.com/pro/api#method-commit

Quote
How I can refresh the grid detail ?

It's straightforward.

When you want to refresh detail grid, you call refresh() on the detail grid.

When you want to refresh row in detail grid, you call refreshRow() on detail grid ( not on the main grid ).

If you are following auto save example, apparently there is no need to call any refresh method, so I'm not clear why you are trying to call refresh methods in the first place.

Can you please share a jsfiddle or complete example through attachment.
« Last Edit: July 29, 2016, 06:07:47 pm by paramquery »