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

5 posts, 0 answers
  1. Gonzalo
    Gonzalo avatar
    11 posts
    Member since:
    May 2013

    Posted 19 Sep 2014 Link to this post

    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>

  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2203 posts

    Posted 23 Sep 2014 Link to this post

    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.

     
  3. Gonzalo
    Gonzalo avatar
    11 posts
    Member since:
    May 2013

    Posted 23 Sep 2014 in reply to Vladimir Iliev Link to this post

    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
  4. Gonzalo
    Gonzalo avatar
    11 posts
    Member since:
    May 2013

    Posted 23 Sep 2014 in reply to Gonzalo Link to this post

    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>")
  5. Gonzalo
    Gonzalo avatar
    11 posts
    Member since:
    May 2013

    Posted 23 Sep 2014 in reply to Gonzalo Link to this post

    Thanks I sorted that out by creating 1 more template column

    thanks a lot
Back to Top