This is a migrated thread and some comments may be shown as answers.

Client side delete still shows item on postback

1 Answer 85 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 30 Jul 2010, 12:17 PM
Hi,
    I'm probably trying to do something that is achieved in a better way but this is what I'm trying to do.

I have a page with several controls and grids that is used for an edit for something else. The page is populated with data from a business object and certain properties are data bound. What I'm trying to do is making changes on the page and then hit a save button which will then postback and I'll read all the data from the controls and save in one hit.

The issue I have is the grid. I'm able to remove the items in the grid client side
        function butConditionRemove_OnClick(grid) {
  
//grid is the clientid of the grid
            var MyGrid = $find(grid);
            var MasterTable = MyGrid.get_masterTableView();
            var selectedRows = MasterTable.get_selectedItems();
            for (var i = 0; i < selectedRows.length; i++) {
                var row = selectedRows[i];
                if (confirm("Are you sure you want to delete the selected entry?")) {
  
                    var table = MasterTable.get_element();
                    var rowtmp = table.rows[row.get_element().rowIndex]
                    table.deleteRow(row.get_element().rowIndex)
  
                               var dataItem = $find(rowtmp.id);
                              if (dataItem) {
                                   dataItem.dispose();
                                   Array.remove($find(grid).get_masterTableView()._dataItems, dataItem);
                            }
                               MyGrid.repaint();
  
                  
                  
                }
  
           
            }
  
         
        }

This works fine but when I click on the save button which is just posting back the grid object on the server side still has the objects I have deleted in it. Other controls on the page which I'm changing as well have the updated values so it's just the grid that does not reflect the changes I make client side.

So is there a way I can make the grid pass it's client side state back in the same way other controls do.

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 04 Aug 2010, 03:08 PM
Hello Paul,

This is correct because RadGrid does not know that item has been removed. In general you can use GridTableView._clientDelete function to trigger client delete(it is used by GridClientDeleteColumn).

However if you perform this action manually you must add itemIndex in RadGrid._deletedItems collection and call updateClientState before item is destroyed.
...
Array.add(<grid>._deletedItems, itemIndex);
<grid>.updateClientState();
...

Later on server RadGrid will fire command with name Delete for each item in this collection so they can be physically deleted on server(same as GridClientDeleteColumn).

Regards,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or