Answered: Correct way to display a foreign key in grid column (as human readable text)
I found some solutions but none of them satisfact me enough. I would like to hear from you which possibilities do I have to display a foreign key text in human readable format. I'll bring you an example
Suppose I have Comment which has these fields: Id, Text, Author_Id
Now there is Author, which has: Id, Name
Author_Id is an int, like Id on both models. Name and Text are strings.
Now I'm displaying a grid containing all comments, but I would like to show to the user instead of an id in Author_Id, the name of the author.
What possibilities do I have to do this? The only way I currently found is loading all Author store (with all records) and eventully render it.
Are there any better solution?
Expecially, if I create a field that is used just to display this value (server side so), like Author_Id_Name, the problem is that if I edit Author_Id in my grid, Author_Id_Name won't get updated because Ext doesn't reload all record but just updates columns I edited.
I prefer to create a view using joined fields. When you update the id, the string value will follow.
This way user can also search the string value.
To me this much better than rendering at the client.
Thanks for suggestion. When you raise your row editor, I imagine you show a selectbox to choose an id (which is integer however). Do you handle the fact that you are updating a "string" value with the int on server side?
I consider yours a valid suggestion, if you can actually update the field.
Still I prefer to show the user a combobox filter instead of string (but that's not a problem I can do the same).
I'll use your technique in my next project I think.
Mhhh... that's how I did it before, however when I update the id field, the string field for some reason doesn't get updated (I have to refresh the store), I think because Ext updates the id field but doesn't read the whole object from the server again, so the string doesn't get updated. I need a way to force the "string field" update too.