EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: rezzonico on February 20, 2014, 09:44:37 AM



Title: Calculate two column values in editing DataGrid
Post by: rezzonico on February 20, 2014, 09:44:37 AM
Hi all,

I am trying to modify the example "Calculate two column values in editing DataGrid" found here:
http://www.jeasyui.com/tutorial/datagrid/datagrid15.php
In this example the involved fields (listprice, amount and unitcost) are numberbox.

The only difference in my situation is that the field "amount" is a combobox (and not a numberbox).
It seems me that for a combobox it's not possible to use the function:
 "amountEditor.target.bind('change')"

The only solution that I have found is to add an "onChange" event to the field "amount".
This event calls a new function (for example setEditing2).

What I do not like in this (working) solution is that "setEditing" and "setEditing2" are two different functions but are very similar.

Is this the only solution or is it possible to use "amountEditor.target.bind('change')" also with combobox ?

Regards.
Miche


Title: Re: Calculate two column values in editing DataGrid
Post by: stworthy on February 20, 2014, 03:41:17 PM
Please try to override the default 'onChange' event handler, in which trigger the 'change' event for the target element:
Code:
$.fn.combobox.defaults.onChange = function(value){
    $(this).val(value);
    $(this).trigger('change');
}


Title: Re: Calculate two column values in editing DataGrid
Post by: rezzonico on February 21, 2014, 06:08:18 AM
It works !
Thanks a lot for your help !

Miche