-
13 Aug 2008 1:12 AM #1
How do I: Property Grid: define custom column names..
How do I: Property Grid: define custom column names..
I had thought that one could define a custom name for each column in a property grid. Not the name/value.. but in the grid itsself.
IE:
select lname, fname, bday from users were ID = 1;
results -> put in store
property grid has headers of Name / Value
but each row is identifed as each column from the store. in this case its lname, fname and bday. i want the lname to be displayed as "Last Name" etc.
In my post: http://extjs.com/forum/showthread.php?t=43390 (2nd one)
I posted one of my custom columns as:
But none of the custom column names is taking. Am i doing something wrong ? I need the ie to remain the same because it had to update the db with it. But i need the display name to be customizable.PHP Code:var comboBoxSecCakeField = new Ext.form.ComboBox({
name:'SecCake'
,hiddenId:'SecCake'
,hiddenName:'SecCake'
,store: SecCakeStore
,displayField: 'name'
,valueField: 'name'
,triggerAction:'all'
,selectOnFocus:true
,mode:'local'
,loadingText:'Loading...'
,typeAhead:true
,allowBlank:true
,emptyText:'Select SecCake...'
,editable:true
});
Thanks for any help
-
13 Aug 2008 2:07 AM #2
Unfortunately the propertyGrid's column model does not allow for renaming of the columns. See this thread: http://extjs.com/forum/showthread.ph...718#post195718
Another thread on the same nature. Not sure if it bears any fruit : http://extjs.com/forum/showthread.php?t=17489
Joshua
-
13 Aug 2008 2:43 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 44
You can rename the columns of a propertygrid by setting:
But if I understand correctly you don't want to change the column names, you want to change the property names.Code:Ext.grid.PropertyColumnModel.prototype.nameText = 'Name'; Ext.grid.PropertyColumnModel.prototype.valueText = 'Value';
For that you can use the (undocumented) propertyNames config option, e.g.
Code:var grid = new Ext.grid.PropertyGrid({ ... propertyNames: { 'lname': 'Last Name', 'fname': 'First Name', 'bday': 'Birthday' } });
-
13 Aug 2008 3:29 AM #4
There is no way to put this in each form element?
IE: new Ext.form.TextField({ allowBlank:false, propertyNames: 'Alternate Field Name' });
yes you are right Condor.. I NEED the value and name to rename as it should be.. but just want a different name displayed.
having lname or fname listed on the property grid is NOT user friendly as Seeing "First name" and "Last Name"!
Terry
-
13 Aug 2008 3:36 AM #5Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 44
The property name/display name mapping (propertyNames) is completely separate from the property name/editor mapping (customEditors).
So you can't specify the display name in the editor, but why would you need to?
-
13 Aug 2008 3:37 AM #6
Only to keep all the config in one place. I mean the way its setup right now i have an array for the new record, columnmodel, custom editors and now iwll have to have one for the names...
-
13 Aug 2008 3:44 AM #7Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 44
Maybe it's easier to use an EditorGridPanel instead.
You could fill your records with the property name, the display name, the value and the editor (all nicely together).
And in the columnmodel you could override getCellEditor to return the editor from the record instead of the one from the column model.
You could look at this post for an example (doesn't do exactly what you want, but you could modify it).
-
13 Aug 2008 4:00 AM #8
Thats a great post and super example.. but sorta seems like a hack to do what a property grid should be able to do effortlessly. I will considering redoing my grid. I only want the displayName and the value shown - a 'valueName' should be the actual db (or store) column name.
The nice thing about what you suggested earlier is that i only have to do it for columns that need a custom name.
Thanks so much for your time and post Condor.
-
13 Aug 2008 6:47 AM #9
This is one of the issues I tried to address with my improved property grid extension, which may interest you: http://extjs.com/forum/showthread.php?t=41390
-
26 Sep 2012 10:53 PM #10
For Ext JS 4:
Code:listeners : { beforerender : function() { var cols = this.getView().getHeaderCt().getGridColumns(); cols[0].setText("Property"); } }



Reply With Quote