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

MasterTableView.set_expanded creates Get request not found

3 Answers 14 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Gregory
Top achievements
Rank 2
Gregory asked on 19 Oct 2015, 03:01 PM

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

 

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 22 Oct 2015, 08:48 AM
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
0
Gregory
Top achievements
Rank 2
answered on 22 Oct 2015, 01:52 PM

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

0
Kostadin
Telerik team
answered on 27 Oct 2015, 11:57 AM
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
Tags
General Discussions
Asked by
Gregory
Top achievements
Rank 2
Answers by
Kostadin
Telerik team
Gregory
Top achievements
Rank 2
Share this question
or