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

Radgrid - display a exception message in batchUpdate?

3 Answers 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yoongu
Top achievements
Rank 1
Yoongu asked on 09 Dec 2014, 01:34 AM
Hello.

I use a RadGrid(BatchMode) and attach grid script.


<telerik:RadGrid ID="grid1" runat="server" Width="100%" Height="165px" AutoGenerateColumns="False" Culture="ko-KR"GroupPanelPosition="Top" OnNeedDataSource="grid1_NeedDataSource" AllowMultiRowSelection="True">                    <ClientSettings>                        <Selecting AllowRowSelect="True"/>                        <Selecting AllowRowSelect="true" UseClientSelectColumnOnly="true"/>                        <Scrolling AllowScroll="True" UseStaticHeaders="True" />                    </ClientSettings>                    <MasterTableView >                        <Columns>                            <telerik:GridClientSelectColumn DataType="System.Boolean"FilterControlAltText="Filter check column" HeaderText="Selection" UniqueName="check">                                <HeaderStyle HorizontalAlign="Center" Width="35px" />                                <ItemStyle HorizontalAlign="Center" />                            </telerik:GridClientSelectColumn>                            <telerik:GridBoundColumn DataField="itemcd" FilterControlAltText="Filter itemcd column" HeaderText="code" UniqueName="itemcd" >                                <ColumnValidationSettings>                                    <ModelErrorMessage Text="" />                                </ColumnValidationSettings>                                <HeaderStyle HorizontalAlign="Center" Width="70px" />                            </telerik:GridBoundColumn>                    </Columns> <ItemStyle Wrap="False"></ItemStyle>                     <HeaderStyle Wrap="True" />                </MasterTableView>            </telerik:RadGrid>







and grid batchUpdatecommand Event



protected void gridDetail_BatchEditCommand(object sender, GridBatchEditingEventArgs e)    {         // this processing is fire database procedure and get return value        string returnmessage = (new WEAU020()).UpdateDetail;                 if (returnmessage.Length > 0)        {            RadAjaxManager1.Alert(returnmessage);            return;                           }         gridDetail.Rebind();    }

in these situation, 

try to BatchEditUpdate, but data is not validation.(Db Check and return meesage)

and i display message to using AjaxManager1.Alert().

It is normally. but happen problem.
explain why problems...

No updated data is loss in grid because not valid(Database procedure check).
but grid has been loss not updated data because occur rebind

I searched document and refernece : http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/simple-vs-advanced/defaultcs.aspx



I checked a these point.
Right after Update/Delete/Insert command event handlers finish execution. You can cancel these operations handling the ItemCommand event and assigning false value to the Canceledproperty of the e event argument

in case batcheditMode , i know way that InsertCommand Event add script : e.Canceled = false;

but case batchEditUpdate event is not work e.Canceled = false;



Conclusion : How can i display a message In BatchEditCommand Event and not rebind?
(don't get a value in client-side why data is keep changing by other user)

3 Answers, 1 is accepted

Sort by
0
Yoongu
Top achievements
Rank 1
answered on 09 Dec 2014, 01:45 AM
First, i try to show meessage  that throw new Exception( [Database return value]).

in this way, not work in radGrid BatchEditCommand event...

0
Viktor Tachev
Telerik team
answered on 11 Dec 2014, 02:41 PM
Hi Yoongu,

I have replied to the support ticket you have posted. Please avoid submitting duplicate threads. This will enable us to keep better track of your support history and provide better answers quicker.

On a side note, if you would like, you can share the answers from the ticket with the community. This can help someone with similar query in the future.

Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Yoongu
Top achievements
Rank 1
answered on 12 Dec 2014, 12:45 AM
-- Reply from support team

Hi,

Note that if the validation is performed on the server-side the RadGrid will need to perform postback. In this scenario any unsaved data will be lost on the client. In order to validate the data on the server I would suggest couple of approaches you could try. 

The first option would be to use different edit mode for RadGrid. This way the unsaved values could be persisted by the controls in the EditForm.

In case you would like to keep the Batch Editing mode you can setup a Web Service for retrieving data from the database. When you need to validate the user input you should use a callback function and validate the data client-side. The callback function will query the Web Service and use the data from it to validate the values entered by the user. This way there will be no postback and the unsaved values will be persisted. 

Let me know if you have further questions.

Regards,
Viktor Tachev 
Telerik Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Tags
Grid
Asked by
Yoongu
Top achievements
Rank 1
Answers by
Yoongu
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or