I have a grid with inline editing enabled. The editor template for one column is a ComboBox which is linked to a dataSource containing currency values and descriptions.
I want to configure this grid so it displays the currency description in the currency column of the table, but the value sent back and forth when editing or adding new rows is the shortened currencyCode (or in another similar instance, a numeric value). It's easy enough to set up a ComboBox to behave this way, displaying text in the dropdown list, but submitting the value; I just want to get the grid cell functioning the same way.
I have tried to figure out how to use the schema "data" or "parse" options, or the transport "parameterMap" option, but between the documentation, the forums, posted examples, the code library, and Google, I still cannot figure out how to get it to work.
if I use parameterMap(data, operation) {} and try to output the "data" to the console with console.log(data) I receive "undefined", whereas upon returning the data, the grid receives it and operates on it perfectly fine. Because of this, I am unable to ascertain the data structure and figure out how to navigate it and modify it.
With the "data" and "parse" options under schema, there are no functional examples I can use. I found an example of using "parse" to convert a value to a date, but that's all. (here)
Does anyone have any useful examples I may have missed that will help me? Or can anyone explain how to use the "parameterMap" "data" and "parse" functions? It should be simple, but without documentation, it is not.
Thank you.
/*
Cost Grid DataSource
*/
var
dataCost =
new
kendo.data.DataSource({
pageSize: 10,
transport: commonTransport({
read:
"/ProjectInfo/GetProjectCost"
,
rData: { projectId: projectId },
update:
"/ProjectInfo/UpdateProjectCost"
,
destroy:
"/ProjectInfo/DestroyProjectCost"
,
create:
"/ProjectInfo/CreateProjectCost"
,
cData: { projectId: projectId }
}),
schema: {
type:
"json"
,
model: {
id:
"projCostId"
,
fields: {
"projCostId"
: { editable:
true
, type:
"number"
},
"costType"
: { editable:
true
, type:
"string"
},
"cost"
: { editable:
true
, type:
"number"
},
"currency"
: { editable:
true
, type:
"string"
}
}
}
}
});
var
costGridColumns = [
{
"field"
:
"costType"
,
"title"
:
"Description"
,
"filterable"
:
true
,
"sortable"
:
true
,
"width"
:
"40%"
},
{
"field"
:
"cost"
,
"title"
:
"Cost"
,
"filterable"
:
true
,
"sortable"
:
true
,
"width"
:
"30%"
},
{
"field"
:
"currency"
,
"title"
:
"Currency"
,
"filterable"
:
true
,
"sortable"
:
true
,
"width"
:
"30%"
,
"editor"
: costGridCurrencyEditor }
],
costGridObject;
/*
Currency ComboBox DataSource
*/
var
dataCurrency =
new
kendo.data.DataSource({
transport: commonTransport({
read:
"/ProjectInfo/GetCurrency"
}),
schema: {
type:
"json"
,
model: {
fields: {
"currencyCode"
: { editable:
false
, type:
"string"
},
"currencyDesc"
: { editable:
false
, type:
"string"
}
}
}
}
});
var
costGridCurrencyComboBox;
function
costGridCurrencyEditor(container, options) {
costGridCurrencyComboBox = $(
'<input id="costGridCurrency" data-bind="value:'
+ options.field +
'" name="'
+ options.field +
'" style="width:auto" />'
)
.appendTo(container)
.kendoComboBox({
dataTextField:
"currencyDesc"
,
dataValueField:
"currencyCode"
,
filter:
"contains"
,
dataSource: dataCurrency
}).data(
"kendoComboBox"
);
}
I have tried to figure out how to use the schema "data" or "parse" options, or the transport "parameterMap" option, but between the documentation, the forums, posted examples, the code library, and Google, I still cannot figure out how to get it to work.
if I use parameterMap(data, operation) {} and try to output the "data" to the console with console.log(data) I receive "undefined", whereas upon returning the data, the grid receives it and operates on it perfectly fine. Because of this, I am unable to ascertain the data structure and figure out how to navigate it and modify it.
With the "data" and "parse" options under schema, there are no functional examples I can use. I found an example of using "parse" to convert a value to a date, but that's all. (here)
Does anyone have any useful examples I may have missed that will help me? Or can anyone explain how to use the "parameterMap" "data" and "parse" functions? It should be simple, but without documentation, it is not.
Thank you.