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

How to use FireCommand in server side

9 Answers 707 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manickam Kishore
Top achievements
Rank 2
Manickam Kishore asked on 13 Oct 2008, 01:51 PM
Hi,

I want to call "InitInsert" through using  firecommand event in server side coding.I need to call this event from Combo box selected index changed event.

please answer this as soon as possible.

Regards,
Kishore

9 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 13 Oct 2008, 02:29 PM
Hi Kishore,

Please check this article for more info:
http://www.telerik.com/help/aspnet-ajax/grdfirecommandeventfromcode.html

Best wishes,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Manickam Kishore
Top achievements
Rank 2
answered on 14 Oct 2008, 05:26 AM
Hi Vlad,

I already gone through which you have sent URL.I need Sample code for fire the firecommand event. I tried myself like some of the given methods from Telerik help,but i could not getting fired the "InitInsert" event.

Kindly send any sample codes.

Regards,
Kishore
0
Princy
Top achievements
Rank 2
answered on 14 Oct 2008, 09:27 AM
Hello Kishore,

Try out the following code to trigger the FireCommandEvent.
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    {       
       if (e.Item is GridDataItem) 
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            string strtxt1 = dataItem["ColumnUniqueName"].Text; 
            if (strtxt1 == "Text") 
            { 
              dataItem.FireCommandEvent("InitInsert", string.Empty); 
            } 
       } 
   } 

Thanks,
Princy.
0
Daniel
Telerik team
answered on 14 Oct 2008, 09:46 AM
Hello Kishore,

This is a possible code-snippet:
RadGrid1.MasterTableView.Items[0].FireCommandEvent("InitInsert", new EventArgs()); 

However it is recommended to use the following approach:
RadGrid1.MasterTableView.IsItemInserted = true;   
RadGrid1.Rebind();   

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Maxim Tairov
Top achievements
Rank 1
answered on 09 Apr 2009, 04:06 PM

Hello Telerik,

Could You please help me in the same problem with using FireCommand method.

Description:

1. I am using fully run-time buid grid.

2. Grid can use internal edit form (default) or my own Pop-Up custom edit form.

3. Insert, Update, Delete events handle in ItemCommand event handler on asp-page

4. In some cases after Inserting new record in dataset which is showed in grid I must make fully reload Grid (columns and content) and automatically OPEN new Inser Form (my custom or default).

Problem:

Method FireCommandEvent("InitInsert", String.Empty) doesn't open Insert form. 

Short Code:

protected void contentGrid_ItemCommand(object source, GridCommandEventArgs e)  
{  
   if (e.Item is GridEditableItem)  
   {  
       if (e.CommandName == "PerformInsert")  
       {  
           //1. Save new data in current dataset  
 
           //2. ReCreate grid  
 
           contentGrid.Rebind();  
           e.Item.FireCommandEvent("InitInsert", String.Empty);  
 
       }  
   }  

Please help me. Is It possible to raise "InitInsert" event from ItemCommand handler?

0
Daniel
Telerik team
answered on 13 Apr 2009, 06:04 PM
Hello Maxim,

Please try the following approach if you want to keep the insert form opened:
protected void contentGrid_ItemCommand(object source, GridCommandEventArgs e)   
{   
   if (e.CommandName == "PerformInsert")   
   {   
       //1. Save new data in current dataset   
       //2. ReCreate grid   
 
       e.Canceled = true
   }   

Kind regards,
Daniel
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Maxim Tairov
Top achievements
Rank 1
answered on 14 Apr 2009, 08:35 AM
Thanks a lot for your proposal. Will try to check this!
0
Srividhya Gopalakrishnan
Top achievements
Rank 1
answered on 07 May 2010, 09:34 PM
Hi Telerik,

I am having similar kind of issue with my fire command. I wanted to call the update event of the rad grid on the click of html button.

I have a nested grid of the form

<rad grid 1>
     <MasterTableView>
           < Columns > ... </columns>
    <DetailTables>
    <GridTableView>
    </GridTableView>
</MasterTableView>
</radGrid1>

I want to fire the update command of the radgrid1 on the click of a html button. I am using the below code and calling the update event from javascript

var

 

detailTablesArray = $find("<%= RadGrid2.ClientID %>").get_detailTables();

 

 

 

var masterTable = detailTablesArray[1];

 

masterTable.fireCommand(

 

"Update",1);

Its firing the update command event, but inside the update command i have condition

 

 

if (e.Item.OwnerTableView.Name == "SomeName")

 

{

 

 

}
this condition is getting failed always. I am unable to retrieve the ownertableview.name from the fire command.
How to achieve this..

please help me to resolve this

0
Rosen
Telerik team
answered on 11 May 2010, 11:28 AM
Hi Srividhya,

We have answered your question in the other thread you have open on this matter.

Sincerely yours,
Rosen
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
Manickam Kishore
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Manickam Kishore
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Daniel
Telerik team
Maxim Tairov
Top achievements
Rank 1
Srividhya Gopalakrishnan
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or