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

[Solved] Grid binds twice when using Ajax Databinding

4 Answers 150 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.
charles
Top achievements
Rank 1
charles asked on 18 Jul 2011, 02:55 PM
Bug?  Or maybe I'm just dumb?

I have a grid that shows a list of Equipment.  Each row has an ActionLink that sends the user to another View that shows a list of the children of that piece of Equipment.  This is the code for that row:

columns.Bound(e => e.Id).ReadOnly().Title("")
.Format(Html.ActionLink(
"Open", "OpenChildren", "Equipment",
new
{ id = "{0}" }, new { @class = "t-button" }).ToHtmlString()).Encoded(false).Width(120);

So the route looks like this: http://localhost/Equipment/OpenChilder/GUID-GOES-HERE

The OpenChildren View is just another grid with the children of the parent and a partial view to show breadcrumbs.  I removed the partial view and it still occurred.

When I don't have Databinding(databinding => dataBinding.Ajax()) set on the grid in OpenChildren, the OpenChildren event only fires once, but the grid doesn't bind.  When i have databinding set to ajax, OpenChildren() fires twice.

What gives?

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 18 Jul 2011, 03:00 PM
Hello Charles,

 I couldn't understand what the problem is. What do you mean that the "OpenChldren" event does not fire? OpenChildren seems to be an action method not an event. Could you provide more code?

Regards,
Atanas Korchev
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
charles
Top achievements
Rank 1
answered on 18 Jul 2011, 03:08 PM

"When I don't have Databinding(databinding => dataBinding.Ajax()) set on the grid in OpenChildren, the OpenChildren event only fires once, but the grid doesn't bind.  When i have databinding set to ajax, OpenChildren() fires twice."

I'm sorry; i really don't know how to put it more clearly than that.  OpenChildren IS an action method though, you are correct.  I'm new to MVC and still call things by their old names.  Like I was saying, when the grid is set to ajax databinding, it databinds normally, but the OpenChildren action method fires twice.  If i remove ajax databinding, it only fires once.  However, the grid does not bind.

OpenChildren firing twice is the core problem here.  It's not that big of a deal right now, but when I get up to a few thousand kits of equipment, that's going to be a lot of info to return to the client twice.

I'm developing this on another network, so moving stuff around is problematic.  Let me know what code you'd like to see and I will hand type it in.

0
Atanas Korchev
Telerik team
answered on 18 Jul 2011, 03:14 PM
Hi Charles,

There is no reason for a hyperlink (which is what Html.ActionLink renders as) to navigate twice except when there is some JavaScript involved. I will need a sample project to help you further. You can attach it to this thread.

Kind regards,
Atanas Korchev
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
charles
Top achievements
Rank 1
answered on 25 Nov 2011, 01:11 PM
DEAR PEOPLE FROM THE FUTURE:

Just found this bug again in my application.  Searched for it, and guess what the first link to come up was?  This one.

Figured it out, though.  I had my GridAction (OpenChildren()) as both the Select method for the grid and the name of the View--so it would fire once to open the view, and then a second time to get the grid.  Separated it out into a discrete View method and a GridAction method and it works fine now.
Tags
Grid
Asked by
charles
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
charles
Top achievements
Rank 1
Share this question
or