This is a migrated thread and some comments may be shown as answers.

[Solved] Binding to Two Variables

1 Answer 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
StevenDom
Top achievements
Rank 1
StevenDom asked on 02 Oct 2014, 05:58 PM
I have a grid where I have a data element that is being received from  my data store as
        schema: {
            model: {
                id: "junkTypeId",
                fields: {
                    junkTypeId: {
                        type: "integer"
                    },
                    junkTypeDesc: {
                        type: "string"
                    }
                }
            }
        }

I display junkTypeDesc in my grid, for that is the human readable form of this datum.I have created a custom popup editor with a dropdownlist of all possible "junks". The dataTextField of the dropdownlist is set to junkTypeDesc and the dataValueField is set to junkTypeId. I have bound the dropdownlist to value:junkTypeId.

The popup editor window works great. The proper initial value is selected in the dropdownlist. I can drop down the dropdownlist and select a new junk. When I press the update button the windows is dismissed and I see (using fiddler) the new value of junkTypeId being sent to the backend but junkTypeDesc is still set to the old text value. In addition, the column in the grid is still set to the old text value.

I know that this is because I am binding to junkTypeId and not junkTypeDesc. But I need to do this because the ID is what is sent to the backend. How can I get  the grid to show the new value of junkTypeDesc after I close the popup editor. Perhaps there is an event that I can attach to to update the appropriate grid cell.

I hope this description makes sense, it is somewhat difficult to describe.

Can anyone help me out with this problem?

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 06 Oct 2014, 12:58 PM
Hi StevenDm,

I would like to point out that there is a syntax mistake in the provided code:
schema: {
    model: {
        id: "junkTypeId",
        fields: {
            junkTypeId: {
                type: "integer" //correct type is "number"
            },
            junkTypeDesc: {
                type: "string"
            }
        }
    }
}


If I understood correctly you would like to save the ID but display the text of the "junk" field. If that is the case, I believe the easiest solution is to use a foreign key column. Please check the corresponding demo page and documentation:
I hope this approach will fit in your scenario.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
StevenDom
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or