Column value is null only inside client template

1 Answer 427 Views
Grid
Adriel
Top achievements
Rank 1
Adriel asked on 14 Oct 2021, 06:09 PM

Hi! I've been trying to figure this out for days. I have a template that works as detail table of a Kendo grid. Inside this template i have several columns wich data I CAN SEE right. But, one column in particular, that include a client template, is always null. When i get ride of the client template i can see the data on the grid provided by the server, but each time I include the client template, the column is null (html code below)

The first column Adjunto works greats, the seconde one is always null. As it can be seen, there are other client template in the grid that work propery. What can i be doing wrong? Thanks in advance. (I added the view with the two columns righ below)

1 Answer, 1 is accepted

Sort by
0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 19 Oct 2021, 03:55 PM

Hello Adriel,

One way in which you can set the ClientTemplate is to utilize a function instead of an inline template.  For example:

Grid Columns

            .Columns(columns =>
            {
                columns.Bound(g => g.Adjunto).Title("Adjuncto");
                columns.Bound(g => g.Adjunto).Title("Adjuncto").ClientTemplate("\\#=checkAdjunto(data)\\#");
            })

ClientTemplate Function

    function checkAdjunto(e) {
        //if Adjunto is not null, provide an image
        if (e.Adjunto) {
            var image = '<img src="/Content/Images/imagen.png" />';
            return image;
        } else {
            return " ";
        }
    }

Please try the approach above, and let me know if you have any questions regarding the matter. 

Regards,
Patrick
Progress Telerik

Remote troubleshooting is now easier with Telerik Fiddler Jam. Get the full context to end-users' issues in just three steps! Start your trial here - https://www.telerik.com/fiddler-jam.
Adriel
Top achievements
Rank 1
commented on 19 Oct 2021, 06:05 PM

Thank you very much, for your time!, i will try your code and see what happens
Patrick | Technical Support Engineer, Senior
Telerik team
commented on 20 Oct 2021, 01:21 PM

Sounds good!  Happy to help!
Tags
Grid
Asked by
Adriel
Top achievements
Rank 1
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Share this question
or