I have a grid set when I'm pulling one of the fields in using an inline drop down list.
I can retrieve the values I need from the dropdown list data item, and i can set the values in the grid's edit row using the dropdown list.
The following code works fine as long as A, B, C, and D are editable... BUT... these values should not be editable. The values in these cells should be driven strictly by the values of the drop down list.
I feel like I should be able to display the values in a template column, but I'm not finding any good documentation on column.template.
7 Answers, 1 is accepted
Ok.... so what I did to "fix" the issue was...
First I created a new editortemplate called ReadOnlyCurrency and placed it in the shared EditorTemplates.
Then for each of the 3 currency columns that this applies to I added the editor template name property.
I then copied the contents of the currency editor template and pasted it into the readonlycurrency template
I turned off the spinners, made it readonly, and made it enabled false.
This is sufficient for what I'm trying to do.
The approach you went for can be used in that scenario. Nevertheless, I would suggest an alternative approach that can also be applied.
In order for a field to be modified it needs to be defined as editable in the DataSource Model configuration. However, you can make the column non-editable via the Editable setting. Check out the article below that describes how to make columns conditionally editable.
The alternative approach you suggest doesn't allow for that.
Honestly... If I could pass the model into the editor, and instead of using a text box all together I could just format using kendo.tostring as a currency and display in a span... that would be ideal...
But with the way the editor passes in the model, I'm unable to get that to work.
When the column is defined as non-endiable and the underlying value in the model can be edited at the same time it is possible to change the value programmatically. However, the change will not be reflected in the Grid immediately. However, the change will be passed to the server. If you would like to update the value in the non-editable Grid cell also you would need to manually modify it.
The video below shows the behavior.
Give the approach a try and let me know how it works on your end.
OK. I get it now. The video did the trick.
Let me re-hash.
First, we leave the fields in the model as editable:
Then in the column binding we set the editable to a function that always returns false:
Then in the change function we set the value in the dataItem AND we set the client side value in the clientRow.
So far, this gives me the functionality that I was looking for.
This is exactly the setup I had in mind. I am glad to hear that you have the functionality up and running.
In case you have additional queries do not hesitate to contact us again.