MasterTableView.set_expanded creates Get request not found

4 posts, 0 answers
  1. Gregory
    Gregory avatar
    15 posts
    Member since:
    Mar 2014

    Posted 19 Oct 2015 Link to this post

    Hello,

    I have a grid with a nested view template. I removed the expand/collapse column to create a customized one.

    In the ItemDataBound method I do the following:

    TableCell tcExpand = item["Expand"];
    Image img = new Image();
    img.ImageUrl = "/images/expand_collapse_plus.gif";
    img.AlternateText = "+";
    img.Attributes.Add("OnClick","ExpandThisMasterTableViewItem(this);");
    tcExpand.Controls.Clear();
    tcExpand.Controls.Add(img);

    On the front end I have: 

    function ExpandThisMasterTableViewItem(sender) {
       var rowIndex = $(sender).closest("tr").attr("id");
       rowIndex = rowIndex.substr(rowIndex.lastIndexOf('_') + 1);
     
       var firstMasterTableViewRow = $find("<%= myGrid.MasterTableView.ClientID %>").get_dataItems()[rowIndex];
       if (firstMasterTableViewRow.get_expanded()) {
          $(sender).closest("tr").find("td").css("background-color", "none");
          $(sender).closest("img[src*='expand']").src = "/images/expand_collapse_plus.gif";
            firstMasterTableViewRow.set_expanded(true);
       }
       else {
          $(sender).closest("tr").find("td").css("background-color", "#DBFEDB");
          $(sender).closest("img[src*='expand']").attr('src', '/images/expand_collapse_minus.gif');
          firstMasterTableViewRow.set_expanded(true);
        }
    }

     

    The line firstMasterTableViewRow.set_expanded always seems to call an image for my custom expand button and I end up with an error :

    GET http://​localserver/mypage/undefined 404 (Not Found)​

    If I comment the line, I do not have that 404 not found error. But i need to expand / collapse my rows.

    Any idea why this error is thrown with that line?

     

    Thank you

     

     

     

     

     

     

     

  2. Kostadin
    Admin
    Kostadin avatar
    1711 posts

    Posted 22 Oct 2015 Link to this post

    Hi Gregory,

    Could you please let me know why you need to create a custom expand/collapse column. I noticed that you are using a image button the same as with the default column. In case you want to change the image you can use ExpandImageUrl and CollapseImageUrl properties.
    Also I am not sure what you mean by "firstMasterTableViewRow.set_expanded always seems to call an image for my custom expand button"? Could you please elaborate a little bit more. Keep in mind when using a client property to expand an item you need to use Client hierarchy load mode.

    Regards,
    Kostadin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Gregory
    Gregory avatar
    15 posts
    Member since:
    Mar 2014

    Posted 22 Oct 2015 in reply to Kostadin Link to this post

    Hello Kostadin.

     I tried to create my custom expand collapse column because i did not manage to apply a custom skin of this column as I wanted to match the rest of the custom skin for the grid .......

    "firstMasterTableViewRow.set_expanded always seems to call an image for my custom expand button" : I meant to say that that line of code triggers a http request for an image... 

    Two things were wrong finally wrong: 
    1 - I had to set HierarchyLoadMode="Client" in the MasterTabbleView tag.

    2 - I had a misspelling of the word 'expand' somewhere in another piece of code i did not publish, not thinking is was relevant :)

     

    Thank you

    Gregory

  5. Kostadin
    Admin
    Kostadin avatar
    1711 posts

    Posted 27 Oct 2015 Link to this post

    Hello Gregory,

    I would recommend you to inspect the expand and collapse elements and change the backdround-image. This is another approach you can use.

    Regards,
    Kostadin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top