EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: arma on March 11, 2015, 05:15:58 AM



Title: Formatter Column Property From PHP Json Encode
Post by: arma on March 11, 2015, 05:15:58 AM
How can i use formatter property value without string quote from PHP json_encode() ?

I have this:
Code:
['field' => 'total_amount', 'formatter' => 'formatAmount', 'title' => 'Month X', 'width' => 150]

after encoded :
Code:
{'field' : 'total_amount', 'formatter' : 'formatAmount', 'title' : 'Month X', 'width' : 150}

What i want is 'formatter' : formatAmount (without quote) otherwise will throw js error :  Uncaught TypeError: string is not a function

Thank you


Title: Re: Formatter Column Property From PHP Json Encode
Post by: arma on March 13, 2015, 01:57:12 AM
Does Jeasui support formatter in string ?


Title: Re: Formatter Column Property From PHP Json Encode
Post by: stworthy on March 13, 2015, 09:31:42 AM
The 'formatter' is a function. You must convert it to a function before using it.
Code:
var column = {'field' : 'total_amount', 'formatter' : 'formatAmount', 'title' : 'Month X', 'width' : 150};
var f = column['formatter'];
if (f){
column['formatter'] = eval(f);
}