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

[Solved] InCell Grid: Problem with ClientTemplates

3 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mathias
Top achievements
Rank 1
Mathias asked on 16 Apr 2012, 04:26 PM
Hi,

I am working with a Grid with InCell Edit-mode. In this grid I want to use ClientTemplates for 2 columns. The problem is, that it seems that it ignores the ClientTemplates! But as soon as I click and leave a cell, the ClientTemplate for this single cell is in use. Thats a little bit confusing. I would be really happy if the Grid would use the templates all the time, not just as soon as I edit a cell.

I have attached a little sample solution which shows my problem. Just run it, click into a cell, then leave it - and you will see the difference.

Did i do something wrong? Hope you can help me.

Thanks,
Mathias

3 Answers, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 17 Apr 2012, 06:11 AM
Hello Mathias,

The client template is not displayed when the data is bound on the server. In the sample project you sent you pass the data to the Grid constructor - this requires to define a Template (instead of ClientTemplate) if you want your data to be formatted initially. Another approach is to remove the data you pass to the constructor (i.e. @(Html.Telerik().Grid<Product>(Model.Files)) and let the Grid perform an Ajax request to fetch its data.


Regards,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Mathias
Top achievements
Rank 1
answered on 17 Apr 2012, 08:29 AM
Oh right, thank you very much. I changed it to a normal Template:

columns.Bound(c => c.Picture).Template(
        @<text>
                <img src="@item.Picture"/>
            </text>
        ).Width(200).Title("Picture");

But now I have the problem that he doesn't update the content of the Picture-column as soon as i edit it. And if I add a new row it does nothing with the selection of the picture. Doesn't bind it and doesn't show something. I think I have to change a little bit more :)

But thanks for your help!
0
Mathias
Top achievements
Rank 1
answered on 17 Apr 2012, 09:42 AM
K my solution for the new problem was to fill the dataItem in the onSave-Event of the Grid.

var filename = $('.t-filename', e.cell.innerHtml);
//Wurde neues File hochgeladen --> So muss der Filename ins dataItem eingetragen werden! --> Nur bei neuen Rows notwendig
if (filename.length != 0)
{
    e.dataItem.Picture = filename[0].innerText || filename[0].textContent;
}

Now everything should work as I want it to work :)
Tags
Grid
Asked by
Mathias
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Mathias
Top achievements
Rank 1
Share this question
or