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

RadGrid Batch Edit fire BatchEditCellValueChanged on KeyPress

5 Answers 176 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Austin
Top achievements
Rank 1
Austin asked on 10 May 2017, 07:55 PM

I would like to know how to have OnBatchEditCellValueChanged even on my batch edit grid to fire on every key press of the edit UI.  Off hand I'm trying to find a way to do it from the MAGIC place holder I have below, in the OnKeyPress event.

 

                        <telerik:GridTemplateColumn HeaderText="Amount" SortExpression="Amount" UniqueName="Amount"
                             HeaderStyle-Width="140px">
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lblAmount" Text='<%# Eval("Amount", "{0:C}") %>'  
                            </ItemTemplate>
                            <EditItemTemplate>
                                <span style="white-space:nowrap;">
                                    <telerik:RadNumericTextBox Width="100%" runat="server" ID="rntAmount" Type="Currency" MaxLength="13" 
                                        NumberFormat-DecimalDigits="2" MinValue="0" ClientEvents-OnKeyPress="MAGIC" />  
                                    </span>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>

 

So far I have played around with:

function MAGIC(sender, args){

            var manager = rgMyRadGrid.get_batchEditingManager();
            var cell = manager.get_currentlyEditedCell();
            var cellValue = manager.getCellValue(cell);

           manager.endUpdate();  //maybe this will auto fire the event?  Didn't seem too...

           manager.changeCellValue(cell, cellValue); //this could work, but is messy... cellValue is the 'old' value prior to key press and it highlights the text every key press.

}

5 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 15 May 2017, 11:35 AM

Hi Austin,

The OnBatchEditCellValueChanged event is not designed to fire when the user types or for validation purposes. It is designed so the developer can transfer complex logic/data object/control structure to their own code.

If you need some sort of validation or DOM operation when editing is done, I can suggest you look into using the OnBatchEditClosing event.

If you need validation, you should use a standard validator control (perhaps a custom validator with a custom JS validation function).

Regards,

Marin Bratanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Austin
Top achievements
Rank 1
answered on 15 May 2017, 01:01 PM

That is the problem.  My entire page is designed using OnBatchEditCellValueChanged... and part of that logic updates several different total values in multiple UI locations.  This is fine... except the user expects the totals value to change without a postback... and this only happens if the user does a field exit.... leading them to think the UI isn't working.  (The user may only use one row of the dozens generated for them on the page before hitting the save button.  That one field exit, hitting save, makes them think the postback fix isn't working.)  lf I can fire the updates on every key press, then that will fix the confusion issue.  I have over 1000 lines of complex code relying on the OnBatchEditCellValueChanged event layered over 12 different batch edit grids.  It would be super if I didn't have to rework all that because of this issue.

I know there is a 'raise event' method, but I can't figure out the syntax to make it work.  I have tried half a dozen of the methods I have seen listed while object exploring in debug, and the raise event method seems like the best bet.  So really if I could just get syntax help on that then it would resolve my problem... even if it wasn't designed to be used that way.  The entire POINT of using Telerik controls was so we could have advanced and complex behavior in a set of UI controls that we didn't have to build by hand, but limitations such as these have led us to drop them in several locations for customized controls or lighter weight controls.  That being the case, I would really like to NOT have to tell my managers that we dropped them from another page after the page was created, tested, and rolled out to hundreds of customers only to have them nitpick a design issue.

0
Marin Bratanov
Telerik team
answered on 15 May 2017, 01:45 PM

Hello Austin,

The syntax of the raiseEvent method is quite simple, as it comes from the MS AJAX framework. The issue is that calling it will probably break just about everything else as it will break the expected lifecycle of the control. There is also the problem of constructing the correct event arguments, as the context is wrong and the necessary information is not available.

Thus, this is not a limitation, but the way the custom project logic is implemented on top of the control. The best advice I can offer at this point is that you extract logic that traverses the DOM to set content of other elements/cells in a separate function that you can call in the keypress event.

You can download the source code from your account and inspect the Grid\BatchEditing\GridBatchEditing.js file to see how the event is raised if you want to look into using it against its intended purpose. Two good starting points are the _createEventArguments and _updateCellValue methods. If you need further help with that, I can put you in touch with our partner network for a bespoke solution.

Regards,

Marin Bratanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Austin
Top achievements
Rank 1
answered on 15 May 2017, 02:19 PM

Yes, the creation/correctness of the event args was my biggest concern.

Extraction of the logic seems like it will be the safest option then, even though this will be a large effort.

I also tried playing around with the 'set focus' logic of the UI to see if I could short cycle the 'on changed' event by setting focus off and then back onto the control with every key stroke... but I came up against several minor little issues that would take more time to correct than worth compared to other design ideas, as well as concern about possible race conditions with UI response versus user type speed.

0
Vasssek
Top achievements
Rank 1
answered on 30 Mar 2018, 08:30 AM

Hello, just follow this link and you will get what you are looking for :-)

https://www.telerik.com/forums/radgrid-batch---on-enter-update#GQFa_aIIakqqX6Qza-XvOQ

Tags
Ajax
Asked by
Austin
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Austin
Top achievements
Rank 1
Vasssek
Top achievements
Rank 1
Share this question
or