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

kendoDropDown inside kendoGrid displays value instead of Text

5 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
adm
Top achievements
Rank 1
adm asked on 17 Oct 2017, 02:48 AM
I'm using the KendoDropDown inside the KendoGrid component. I have been trying for three days to display the Text instead of the value. I've use a model and schema, tried with valuePrimitive, dataTextField, template, but anything seems to work... I'm tired of following examples which just don't work. I'm attaching a JavaScript file with the code I'm using.

5 Answers, 1 is accepted

Sort by
0
adm
Top achievements
Rank 1
answered on 17 Oct 2017, 02:49 AM
This is the file.
0
adm
Top achievements
Rank 1
answered on 17 Oct 2017, 02:50 AM
Third time trying to upload the file...
0
adm
Top achievements
Rank 1
answered on 17 Oct 2017, 02:52 AM
Come on! I can't upload the zip file because the form of the forum crash... 
Sorry but I'm desperate now so I'm going to paste the code here...

// THIS IS THE JSONSTRING RETURNED BY THE DATA SOURCE TRANSPORT
[
{
"_sattoci_id":1,
"_sattoci_max":0
},{
"_sattoci_id":2, // This is what I'm getting
"_sattoci_max":0.16 // This is the value I expect when I finalize editing mode
}
]

// CUSTOM EDITOR
function ivaEditor(container, options) {
$('<input name="' + options.field + '" />')
.appendTo(container)
.kendoDropDownList({
// When avalue primitive is false there's no difference
// valuePrimitive: false,
valuePrimitive: true,
optionLabel: "SIN IVA",
autoBind: true,
dataValueField: "_sattoci_id",
dataTextField: "_sattoci_max",
dataSource: {
transport: {
read: "/api/SatCatTasasImpuestos/ivaT",
dataType: "json",
}
}
});
}

var conceptosGridData = new kendo.data.DataSource({
schema: {
model: {
id: "cve_producto",
fields: {
cta_predial: {type:"string", nullable:true},
no_pedimento: {type:"string", nullable:true},
// I've remove nullable from column definition because some people suggest to do so
// iva: {type:"string", nullable:true},
iva: {type:"string"},
}
}
}
});

var conceptosGrid = $("#grid-conceptos").kendoGrid({
dataSource: conceptosGridData,
save: onSave,
height: 350,
scrollable: true,
resizable: true,
columns:[{
width: 150,
editor: ivaEditor,
field: "iva",
title: "IVA"
// This alternative shows undefined
// template: "#=iva._sattoci_max#",
// This alternative shows the value instead of the text
// template: "#=iva#",
}],
editable: "inline"
}).data("kendoGrid");
0
Stefan
Telerik team
answered on 18 Oct 2017, 12:27 PM
Hello,

Thank you for the provided information.

I made an example based on the provided code and it is working as expected on my end.

Please check it and advise if it defers from the real application scenario:

http://dojo.telerik.com/AFeDiy

If additional assistance is needed, the example can be used for reference to demonstrate the issue.

---------------------

As for the zip upload, I apologize for the inconvenience caused by the server upload.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Tom
Top achievements
Rank 1
answered on 05 Sep 2018, 01:54 PM

For MVC you need to use the method like. You will need to specify the ViewData in the code behind

columns.ForeignKey(e => e.TotalRewardFieldType, (System.Collections.IEnumerable)ViewData["FieldTypes"], "Value", "Text").EditorTemplateName("FieldType");

Tags
Grid
Asked by
adm
Top achievements
Rank 1
Answers by
adm
Top achievements
Rank 1
Stefan
Telerik team
Tom
Top achievements
Rank 1
Share this question
or