kendoDropDown inside kendoGrid displays value instead of Text

6 posts, 0 answers
  1. adm
    adm avatar
    5 posts
    Member since:
    Apr 2014

    Posted 16 Oct 2017 Link to this post

    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.
  2. adm
    adm avatar
    5 posts
    Member since:
    Apr 2014

    Posted 16 Oct 2017 Link to this post

    This is the file.
  3. adm
    adm avatar
    5 posts
    Member since:
    Apr 2014

    Posted 16 Oct 2017 Link to this post

    Third time trying to upload the file...
  4. adm
    adm avatar
    5 posts
    Member since:
    Apr 2014

    Posted 16 Oct 2017 Link to this post

    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");
  5. Stefan
    Admin
    Stefan avatar
    3008 posts

    Posted 18 Oct 2017 Link to this post

    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.
  6. Tom
    Tom avatar
    10 posts
    Member since:
    Sep 2017

    Posted 05 Sep 2018 Link to this post

    For MVC you need to use the foreignkey 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");

Back to Top