EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: yulei on February 12, 2019, 08:01:41 AM



Title: how to get the field name inside an styler function?
Post by: yulei on February 12, 2019, 08:01:41 AM
this post :https://www.jeasyui.com/forum/index.php?topic=4940.msg12207#msg12207 (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,...)?


Title: Re: how to get the field name inside an styler function?
Post by: stworthy 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>