EasyUI Forum
April 27, 2024, 01:57:38 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: propertygrid needs a label  (Read 21414 times)
eggbert
Newbie
*
Posts: 16


View Profile Email
« on: July 26, 2011, 09:30:07 AM »

Hi,

I am just getting started with jquery easy ui.  I am really impressed so far.  However, one thing that is driving me crazy is that the propertygrid component has no "label" for the key... For example, a row of the json to load a property grid looks like:

Code:
{"name":"user_name","value":"Bill Smith","group":"ID Settings","editor":"text"}

So then then in the grid it looks like..

user_name - Bill Smith

I am using the key value pair from my database to simplify  things E.g "user_name" 

Would it not be good to have a label? So that I could do something like...

Code:
{"name":"user_name","label":"User Name","value":"Bill Smith","group":"ID Settings","editor":"text"}


I've tried to use the formatter property to format the "name" field, but it does not seem to work with property grid.


Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 26, 2011, 11:38:46 PM »

Override the 'columns' property and you can customize the columns and display the 'label' field.

Code:
$('#tt').propertygrid({
width:300,
height:'auto',
url:'propertygrid_data.json',
showGroup:true,
scrollbarSize:0,
columns:[[
{field:'label',title:'Label',width:100,resizable:true},
{field:'value',title:'Value',width:100,resizable:false}
]]
});
Logged
eggbert
Newbie
*
Posts: 16


View Profile Email
« Reply #2 on: July 27, 2011, 10:13:03 AM »

Thanks for the reply.

Actually,  what I need is an additional field, but I can't seem to get propertygrid to bend to my will. 

Say I have a field/key called user_name.  I would not want to display "user_name" in the propertygrid, but rather User Name.   The label would be the "user presentable" string for the field.

So i'd have:

name = user_name:  The actual key/name, probably a database column.
label = User Name: - The user-friendly label of user_name, used ONLY for presentation.




Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: July 27, 2011, 11:34:40 PM »

Define the 'formatter' function for your 'name' field:

Code:
$(function(){
$('#tt').propertygrid({
width:300,
height:'auto',
url:'propertygrid_data.json',
showGroup:true,
scrollbarSize:0,
columns:[[
{field:'name',title:'Name',width:100,resizable:true,
formatter:function(value,row){
return row.label;
}
},
{field:'value',title:'Value',width:100,resizable:false}
]]
});
});
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!