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

how to call a oncommand clientevent and onitemdatabound server event in a radgrid ?

5 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neeraj
Top achievements
Rank 1
Neeraj asked on 07 Jun 2009, 07:53 PM
 
I have the following radgrid, when I put the clientevent - OnCommand - "OnGridCommand" the serverevent
 
OnItemDataBound="gridInvLines_ItemDataBound" is not being called - why is that ? How can I modify the code to call the serverevent or move the server code to client event ?
 
Basically I am trying to check if the page is valid or not , if the page is valid only then open the popup and load some preexisting values else do not open the popup. The code works except the values are not being generated i.e. OnItemDataBound="gridInvLines_ItemDataBound is not being called ?
 
 
 
<telerik:RadGrid ID="gridInvLines" AllowPaging="False" Skin="Office2007"

 

runat="server" AutoGenerateColumns="False" DataSourceID="odsInvLines"

 

GridLines="None" OnItemDataBound="gridInvLines_ItemDataBound" ShowFooter="True">

 

<ClientSettings >

 

<ClientEvents OnKeyPress="disableEnterKey" OnCommand="OnGridCommand" OnPopUpShowing="PopUpShowing" />

 

</ClientSettings>

 

<MasterTableView DataKeyNames="LINE_NUMBER" DataSourceID="odsInvLines" EditMode="PopUp" InsertItemDisplay="Top" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add New Line">

 

<Columns>

 

<telerik:GridEditCommandColumn ButtonType="LinkButton" InsertText="Save" UniqueName="EditButton">

 

<ItemStyle HorizontalAlign="Center" Width="30px" />

 

</telerik:GridEditCommandColumn>

 

</Columns>

 

 

<EditFormSettings EditColumn-UpdateText="Save" EditColumn-InsertText="Save" CaptionFormatString="Invoice Line Information" ColumnNumber="2">

 

<FormTableItemStyle Wrap="False" Width="100%"></FormTableItemStyle>

 

<FormCaptionStyle CssClass="EditFormHeader" Width="100%"></FormCaptionStyle>

 

<FormMainTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="3" BackColor="White"

 

Width="100%" />

 

<FormTableStyle CellSpacing="0" CellPadding="2" CssClass="module" Height="110px"

 

BackColor="White" />

 

<FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>

 

<PopUpSettings Modal="true" Width="600" />

 

</EditFormSettings>

 

</MasterTableView>

 

<ValidationSettings CommandsToValidate="PerformInsert,Update" />
 
//client javascript

function

OnGridCommand(sender, eventArgs)

{

 

if(eventArgs.get_commandName() == "Edit" || eventArgs.get_commandName() == "InitInsert" )

{

 

if (!Page_ClientValidate()) return false;

}

 

 

}

//server event

 

protected void gridInvLines_ItemCommand(object source, GridCommandEventArgs e)

{

 

switch (e.CommandName)

{

 

case RadGrid.InitInsertCommandName:

e.Canceled =

true;

 

//this is for the Calendar Date control

System.Collections.Specialized.

ListDictionary newValues = new System.Collections.Specialized.ListDictionary();

 

if(radBillPeriodStartDate.SelectedDate.HasValue)

newValues[

"BEGIN_BILLING_PERIOD"] = Convert.ToDateTime(radBillPeriodStartDate.SelectedDate);

 

if(radBillPeriodEndDate.SelectedDate.HasValue)

newValues[

"END_BILLING_PERIOD"] = Convert.ToDateTime(radBillPeriodEndDate.SelectedDate);

e.Item.OwnerTableView.InsertItem(newValues);

 

 

 

break;

 

default:

 

break;

}

}

 

 
 
 

5 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 11 Jun 2009, 08:41 AM
Hello Neeraj,

Generally, wiring the OnCommand client event of the grid should not affect the ItemDataBound server event handler in case it is properly attached.

Can you please verify that you are using the latest version 2009.1.527 of RadControls for ASP.NET AJAX in your project and the page is submit as expected after the validation check inside the OnCommand handler is passed? You may also check whether OnInit/OnLoad of the page or other postback event handlers of the grid or other controls on the page are raised as expected.

Let us know what your findings are in order to advice you further.

Best regards
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Neeraj
Top achievements
Rank 1
answered on 11 Jun 2009, 03:10 PM
One thing I want to apologize is I was talking about the OnItemCommand="gridInvLines_ItemCommand"  event not the 

OnItemDataBound.

When we have OnCommand clientevent , then the OnItemCommand is not being called -   2008.3.1314.35 is the version of my rad controls - would upgrading eliminate this problem ?
0
Sebastian
Telerik team
answered on 12 Jun 2009, 07:48 AM
Hello Neeraj,

Try upgrading to the latest version of the suite to see whether this helps. Let us know how it goes.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
NetDeveloper1107
Top achievements
Rank 1
answered on 28 Apr 2010, 06:59 AM
Hi,

I am using Telerik Version=2009.2.826.20 version, I have Radgrid for which I have Oncommand event at client side and also OnItemCommand event on server side but Server side event is not getting executed. Is it possible or not?

Thanks
0
Sebastian
Telerik team
answered on 28 Apr 2010, 08:59 AM
Hello NetDeveloper1107,

Please channel the communication on this subject in the other forum post you participated in to avoid duplicate posts.

Kind regards,
Sebastian
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
Neeraj
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Neeraj
Top achievements
Rank 1
NetDeveloper1107
Top achievements
Rank 1
Share this question
or