EasyUI Forum
May 09, 2024, 03:43:58 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: how to add "formatter" using json?  (Read 6755 times)
proffl
Newbie
*
Posts: 7


View Profile Email
« on: July 06, 2014, 03:53:27 AM »

hi, i'm now using properygrid for editing entity,  here is my property json like below:
Code:
string json = "{\"total\":6,\"rows\":[";
            json += "{\"name\":\"id\",\"value\":\""+ID+"\"}";
            json += ",{\"name\":\"name\",\"value\":\"" + Name + "\",\"editor\":\"text\"}";
            json += ",{\"name\":\"path\",\"value\":\"" + Url + "\",\"editor\":\"text\"}";
            json += ",{\"name\":\"icon\",\"value\":\"<span class='icon " + Icon +
                "'>&nbsp;</span>\",\"editor\":{\"type\":\"combobox\",\"options\":{\"valueField\":\"id\",\"textField\":\"name\",\"url\":\"/Icon.aspx\",\"groupField\":\"group\"}}}";
            json += "]}";
and i wanna my icon's editor display icon image. instead of text, so i change editors to :
Code:
\"editor\":{\"type\":\"combobox\",\"options\":{\"valueField\":\"id\",\"textField\":\"name\",\"url\":\"/Icon.aspx\",\"groupField\":\"group\",\"formatter\":\"function(row){brbr}\"}}}";
but it seems javascript take "function(row){brbr}" as string instead of function.
how can i add formatter to the editor ?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: July 06, 2014, 07:23:08 PM »

The 'formatter' must be defined in the columns definitions. Please try this:
Code:
$('#pg').propertygrid({
columns:[[
{field:'name',title:'Name',width:100,sortable:true},
{field:'value',title:'Value',width:100,resizable:false,
        formatter:function(value){
        return value;
        }
}
    ]]
})
Logged
proffl
Newbie
*
Posts: 7


View Profile Email
« Reply #2 on: July 07, 2014, 07:30:21 AM »

thanks for the reply.
as i'm using propertygrid, and i just need one of my property's editor using formatter. so i extends the editor and add formatter to it's options then, fix the problem.
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!