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

Auto rebind after command execution

6 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Den
Top achievements
Rank 1
Den asked on 24 May 2012, 07:26 AM
Hi!

I am using RadGrid. There is GridButtonColumn(CommandName = "DeleteCommand") for deleting a row.    
onCommand: function (sender, eventArgs) {
   var commandName = eventArgs.get_commandName();
   if (commandName == "DeleteCommand") {
      var dataItems = eventArgs.get_tableView().get_dataItems();
      var dataItem = dataItems[eventArgs.get_commandArgument()].get_dataItem();
      deleteRow(dataItem);
   }

It works, but after deleting grid is rebinded. How can I turn off auto rebind?
I've found "Commands that invoke Rebind() implicitly" topic and change the command name. But It doesn't work.
I tried to use eventArgs.set_cancel(true). But It doesn't work too.

Thanks for your help! 

6 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 24 May 2012, 11:42 AM
Hello Den,

From server side you can cancel the event.
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "DeleteCommand")
        {  
            e.Canceled = true;
        }
    }


Thanks,
Jayesh Goyani
0
Den
Top achievements
Rank 1
answered on 24 May 2012, 12:33 PM
Hello Jayesh,
Thanks for your reply.
I do not use a server code. I use the following grid settings:
<ClientSettings>
   <DataBinding Location="~/Services/MaintenancePlans.asmx" SelectMethod="GetActivity">
   </DataBinding>
   <ClientEvents OnCommand="page.onCommand" OnDataBinding="page.gridDataBinding" OnRowDataBound="page.gridRowDataBound" />
</ClientSettings>

Do you have any idea? 
0
Jayesh Goyani
Top achievements
Rank 2
answered on 24 May 2012, 01:41 PM
Hello Den,

function myCommand(sender, args) {
               args.set_cancel(true);
           }
<ClientEvents  OnCommand="myCommand" />


Thanks,
Jayesh Goyani
0
Den
Top achievements
Rank 1
answered on 24 May 2012, 01:48 PM
I've modified the function.
   onCommand: function (sender, eventArgs) {
      eventArgs.set_cancel(true);
      var commandName = eventArgs.get_commandName();
      if (commandName == "DeleteCommand") {
         var dataItems = eventArgs.get_tableView().get_dataItems();
         var dataItem = dataItems[eventArgs.get_commandArgument()].get_dataItem();
         deleteActivity(dataItem);
      }
}

It doesn't work.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 24 May 2012, 01:53 PM
Hello,

Please try with below code snippet.
onCommand: function (sender, eventArgs) {
      eventArgs.set_cancel(true);
    
      }
}

Let me know cancel the Rebind or not.

Thanks,
Jayesh Goyani
0
Den
Top achievements
Rank 1
answered on 24 May 2012, 02:14 PM
I 've tried to use this. Message shows "true". But it does not work. The grid is rebinded.
onCommand: function (sender, eventArgs) {
   eventArgs.set_cancel(true);
   alert(eventArgs.get_cancel());
},
Tags
Grid
Asked by
Den
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Den
Top achievements
Rank 1
Share this question
or