New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
Update Calculated Columns Client-side
When using GridCalculatedColumns the calculated value is based on the values in the data source. When editing cells in Batch Edit mode the modifications are initially performed only on the client. Thus, the calculated field will be updated after the changes are saved.
The following sample illustrates how you can use JavaScript to update the calculated value immediately after the user makes a modification.
ASP.NET
<telerik:RadGrid RenderMode="Lightweight" runat="server" ID="RadGrid1"
OnNeedDataSource="RadGrid1_NeedDataSource"
AutoGenerateColumns="false"
AutoGenerateEditColumn="true"
AllowSorting="true"
AllowPaging="true" PageSize="10"
OnUpdateCommand="RadGrid1_UpdateCommand"
OnInsertCommand="RadGrid1_InsertCommand">
<ClientSettings>
<ClientEvents OnBatchEditClosed="batchEditClosed" />
</ClientSettings>
<MasterTableView CommandItemDisplay="Top" DataKeyNames="ID" EditMode="Batch">
<Columns>
<telerik:GridBoundColumn DataField="ID" HeaderText="ID" UniqueName="ID" ReadOnly="true" InsertVisiblityMode="AlwaysVisible">
</telerik:GridBoundColumn>
<telerik:GridNumericColumn DataField="NumericField1" HeaderText="NumericField1" UniqueName="NumericField1">
</telerik:GridNumericColumn>
<telerik:GridNumericColumn DataField="NumericField2" HeaderText="NumericField2" UniqueName="NumericField2">
</telerik:GridNumericColumn>
<telerik:GridCalculatedColumn UniqueName="CalculatedColumn1" HeaderText="Calculated Column"
DataFields="NumericField1, NumericField2" DataType="System.Int32" Expression="{0}+{1}">
</telerik:GridCalculatedColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>