View Full Version : Property grid - changing propertyNames dynamically

23 Oct 2012, 3:18 PM
I'm trying to use my PropertyGrid component in Sencha Architect with different objects, so the set of properties it is supposed to display is not fixed.

While I have no problems assigning new fields and values for it to display (myGrid.setSource({field: "value"}), I can't find any similar setter method to change display names for those fields (e.g. "Last Name" to be shown for field "last_name").

In design time this is controlled by property "propertyNames" (no pun intended), but assigning to it directly in run time (myGrid.propertyNames = {field: "My Field Name"}) seem to work very weirdly - only one out of several field names assigned in that way is displayed.

On top of that, ExtJS documentation tells "propertyNames" is deprecated (while it still appears in Sencha Architect with no obvious alternative).

So the questions are:

1. Is changing "propertyNames" property of a PropertyGrid the right way to achieve what I want (to specify display names for fields loaded via "source" of the grid)?
2. If so, how should it be accessed, is there a setter method I'm supposed to use?
3. Do I need to redraw grid after that (might explain why not all the field names are displayed when I assign it directly).

Please feel free to ask for more details if it doesn't make much sense.

Many thanks in advance.

23 Oct 2012, 10:38 PM
Solved it:

1. Directly assigning new config to myGrid.propertyNames works actually works fine.
2. This should be done BEFORE a new source is assigned - apparently setSource() redraws the grid while assigning to the property doesn't.

So what happened to me when only some of the field names were shown, these were the names which also existed in the previously assigned set. Because first the source was set, its fields existed by coincidence in propertySet config before were shown correctly, and its tailored config assigned later had no effect until new setSource was set.