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

Item_command InitInsert

4 Answers 300 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cush
Top achievements
Rank 1
Cush asked on 04 Jul 2011, 05:36 PM
Hi All

I am calling the insert form of radgrid using the fireCommand from javascript that is triggered by and external button,
However seeing as i am using a custom command name it will not trigger unless the grid has some data,
I tried changing the command name to InitInsert....however this does not trigger the grids Item_command server side for some reason!

I need to trigger the Item_command as i need to control the event.

Could someone tell me why this is not triggering using InitInsert and it triggered using my custom command?

Many Thanks

Regards

Cush

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Jul 2011, 08:34 AM
Hello Cush,

When firing custom commands they are fired through the first data item in the GridTableView. This means that no command will be fired if the grid is bound to an empty data source.

Hope the information helps.

Thanks,
Princy.
0
Cush
Top achievements
Rank 1
answered on 05 Jul 2011, 08:43 AM
Hi Princy

Thanks for the reply.
I found that out yesterday hence my post,
I changed the fireCommand to InitInsert and the form opens fine , however this does not seem to be triggering the Item_command event?
I have used this many times before but with a button in the command template & the Item_Command triggers no problem, but on this occassion i need to use the fireCommand from javascript and it doesnt seem to be triggering it?
When i was using the custom command and the grid had data it would trigger the Item_Command every time??

So it you have any idea why it is not being triggered i would appriciate your help.

Many Thanks

Best Regards

Cush
0
Accepted
Iana Tsolova
Telerik team
answered on 07 Jul 2011, 09:17 AM
Hello Cush,

For the ItemCommand server-side event to be fired RadGrid should know which is the command and from which Item is the command invoked. In your case the CommandName is clear, but I assume you have the CommandItemDisplay property set to None. Thus the grid cannot get reference to the GridCommandItem and pass it as a second argument of the ItemCommand event and that is why the ItemCommand event is not fired.
To overcome the issue I suggest that you set the CommandItemDisplay property to Top for instance and then hide as below on RadGrid PreRender:
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)[0].Display = false;
}


Regards,
Iana
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Cush
Top achievements
Rank 1
answered on 07 Jul 2011, 12:45 PM
Hi Iana

Thanks very much for the suggestion it worked a treat.
I must admit i didnt even consider hiding the command template!

Many Thanks Again

Regards

Cush
Tags
Grid
Asked by
Cush
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Cush
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or