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

update the parent row - based on child-template "text/kendo-tmpl -

4 Answers 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gonzalo
Top achievements
Rank 1
Gonzalo asked on 19 Sep 2014, 09:12 AM
I want to add an image to parent row depending on the value in child row.
Below is my main grid and template code

If FeedBackForm.FeedBackQA[i].Answer is not null I need image on parent row
find complete code attached.
Please guide


  .ClientDetailTemplateId("template")   



    <script id="template" type="text/kendo-tmpl">
        <div>
            <div class="feedbackQuestion">
                # for (var i = 0; i < FeedBackForm.FeedBackQA.length; i++) { #
                <ul>
                    <li>#= FeedBackForm.FeedBackQA[i].Question #   <span class="feedbackanswer">    #= FeedBackForm.FeedBackQA[i].Answer #</span></li>
                </ul>
               
                # } #
            </div>
          
        </div>
       
    </script>

4 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 23 Sep 2014, 08:06 AM
Hi Gonzalo,

Please check the example below of how you can call external JavaScript function from the template in which to make additional calculations and return value which to be used in the template:

.ClientTemplate("<a href='" + Url.Action("RefreshTableAjaxFromOtherPage", "Map", new { SessionId = "#=SessionID#", Latitude = "#=Latitude#", Longitude = "#=Longitude#", Country = "#=Country#" }) + "' style='display:block;text-align:center;'>#=getImageForModel(data)#</a>")
 
<script>
    function getImageForModel(model) {
        var showImage = true;
        for (var i = 0; i < model.FeedBackForm.FeedBackQA.length; i++) {
            if(!model.FeedBackForm.FeedBackQA[i].Answer) {
                showImage = false;
            }
         }
 
         if (showImage) {
            return "<img  src='./Content/Images/icon_location_color.png' />";
         }
         return "";
    }
</script>

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Gonzalo
Top achievements
Rank 1
answered on 23 Sep 2014, 03:02 PM
That's very helpful, but is there a way I can make image as first column of grid and hide/un-hide depending on condition
0
Gonzalo
Top achievements
Rank 1
answered on 23 Sep 2014, 03:04 PM
That's very helpful, but is there a way I can make image as first column of grid and hide/un-hide depending on condition.
First column of Parent Row of grid and hide/unhide depending on condition of child row

As of now I have added it in template and appearing as last column of grid

  columns.Template(@<text></text>)
                  .ClientTemplate("<a href='" + Url.Action("RefreshTableAjaxFromOtherPage", "Map", new
                  {
                      SessionId = "#=SessionID#",
                      Latitude = "#=Latitude#",
                      Longitude = "#=Longitude#",
                      Country = "#=Country#"
                  }) + "' style='display:block;text-align:center;'><img  src='../../Content/Images/icon_location_color.png' />#=getImageForModel(data)#</a>")
0
Gonzalo
Top achievements
Rank 1
answered on 23 Sep 2014, 03:43 PM
Thanks I sorted that out by creating 1 more template column

thanks a lot
Tags
Grid
Asked by
Gonzalo
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Gonzalo
Top achievements
Rank 1
Share this question
or