EasyUI Forum
May 16, 2024, 01:36:57 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: onClickRow in datagrid  (Read 17286 times)
varonica
Full Member
***
Posts: 106


View Profile
« on: August 18, 2013, 08:08:59 PM »

onClickRow in datagrid is perfect but I want to add a 'keyup' event after 'onClickRow' event is fired up to some numberbox to get updated without clicking to other rows or accept it.  



The problem i'm facing right now is the value i'm getting is not a current value but a previous value. I want a current value not a previous one.

Example:
after i type '23' in numberbox it gives me '2' instead of '23'.

Please help me Sad Sad Sad
« Last Edit: August 18, 2013, 08:17:33 PM by varonica » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: August 19, 2013, 12:17:28 AM »

After calling 'beginEdit' method to edit a row, the 'numberbox' editor can be obtained by calling 'getEditor' method. Thus you will be able to bind any events on this editor. The code below shows how to achieve this functionality.
Code:
var dg = $('#dg');
dg.datagrid('beginEdit', index);
var ed = dg.datagrid('getEditor', {
  index: index,
  field: 'hours'
});
$(ed.target).keyup(function(){
  var val = $(this).val();
});
Logged
varonica
Full Member
***
Posts: 106


View Profile
« Reply #2 on: August 19, 2013, 12:57:10 AM »

I have tried it but it isn't working Sad Can you show me a complete example ?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: August 19, 2013, 01:11:38 AM »

Please refer to this example http://jsfiddle.net/CsyY2/.
Logged
varonica
Full Member
***
Posts: 106


View Profile
« Reply #4 on: August 19, 2013, 01:22:14 AM »

Thanksssssssssssssssssssssssssssssssssssssssssssssssssss!!!! Smiley  Grin Grin Grin Grin Grin Grin Tongue Tongue Tongue Tongue Tongue Tongue
Logged
varonica
Full Member
***
Posts: 106


View Profile
« Reply #5 on: August 19, 2013, 02:41:05 AM »

Can i update row without endEdit ? Sad
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #6 on: August 19, 2013, 04:30:04 AM »

Calling endEdit method will stop the row editing and update that row.
Logged
varonica
Full Member
***
Posts: 106


View Profile
« Reply #7 on: August 20, 2013, 01:52:10 AM »

Let say after i enter '23' into Wattage of Device, 'Cost Per Hour' need to update its value without calling endEdit method. Can i do that ?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #8 on: August 20, 2013, 07:00:04 AM »

This tutorial shows how to calculate two columns.
http://www.jeasyui.com/tutorial/datagrid/datagrid15.php

As an alternate solution, extend a new editor 'label' that only display field value and apply it to your 'Cost Per Hour'. This topic shows how to achieve this label editor.
http://www.jeasyui.com/forum/index.php?topic=1803.0
Logged
varonica
Full Member
***
Posts: 106


View Profile
« Reply #9 on: August 20, 2013, 08:55:37 PM »

Thanks sir, You save me again !!!!  Embarrassed Embarrassed Embarrassed Embarrassed Embarrassed Embarrassed Kiss Kiss Kiss Kiss Kiss Kiss Wink Wink Wink Wink Tongue Tongue Tongue Tongue Tongue Tongue Tongue
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!