EasyUI Forum
October 16, 2025, 12:03:52 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: how to get the field name inside an styler function?  (Read 6763 times)
yulei
Newbie
*
Posts: 9


View Profile Email
« on: February 12, 2019, 08:01:41 AM »

this post :https://www.jeasyui.com/forum/index.php?topic=4940.msg12207#msg12207
is  become invalid。
when i console.log(this) in the styler function ,i print the table .

in the old versions ,  datagrid call styler directly , now it use  styler.call('datagridTarget',...).

can styler  add a field param after (value,row,index,...)?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 12, 2019, 06:16:42 PM »

Define a function that accepts the 'field' parameter and return the 'styler' function.
Code:
function mystyler(field){
return function(value){
if (value=='RP-SN-01'){
console.log(field)
return 'color:blue'
}
}
}

And then apply it to the column.
Code:
<th data-options="field:'productid',width:100,
styler: mystyler('productid')
">Product</th>
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!