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

[Solved] Grid Refresh question

7 Answers 45 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.
David
Top achievements
Rank 1
David asked on 17 Aug 2011, 06:20 PM
Hello,
 I have the following code:
    <% Html.Telerik().Grid<BuyOffersTable>()
        .BindTo(Model)
        .DataKeys(datakeys => datakeys.Add(c => c.BuyOfferGUID))
        .DataBinding(dataBinding => dataBinding.Ajax().Select("_BuyOffersTablesBinding", "BuyLetters"))
        .Name("BuyOffersTable")
        .Columns(columns =>
                    {
                        columns.Bound(o => o.BuyOfferGUID).Hidden(true);
                        columns.Bound(o => o.BuyOfferGUID).ClientTemplate("<a href='" + Url.Action("RequestDetails") + "/<#=BuyOfferGUID #>Select</a>")
                        .Template(o => { %><%=Html.ActionLink("B"+o.BuyOfferNumer, "BuyLetters", new { id = o.BuyOfferGUID })%><% }).Title("");
                        columns.Bound(o => o.BuyOfferNumer).ClientTemplate("B<#=BuyOfferNumer #>").Template(o => { %>B<%=o.BuyOfferNumer%><% }).Title("Offer #");
                        columns.Bound(o => o.Createdate).Title("Created");
                        columns.Bound(o => o.FirstName).Title("First Name");
                        columns.Bound(o => o.LastName).Title("Last Name");
                    })
                    .Sortable()
                    .Scrollable()
                    .Pageable()
                    .Render();
 
%>

I get 3 records on the inital view.  But when i refresh I only get 1 record back but both Controller functions have the same linq query

here is the controller code, how do i make this work right?

[GridAction]
      public ActionResult _BuyOffersTablesBinding()
      {
          WebEntities storedb = new WebEntities();
 
          IQueryable<BuyOffersTable> BuyOffersTables = storedb.BuyOffersTables;
 
          BuyOffersTables = from o in BuyOffersTables
                            where o.Processed == false
                            select o;
           
          return View(new GridModel(BuyOffersTables));
           
      }
 
 
 
      public ActionResult ProcessIncoming()
      {
          WebEntities storedb = new WebEntities();
          IQueryable<BuyOffersTable> BuyOffersTables = storedb.BuyOffersTables;
 
          BuyOffersTables = from o in BuyOffersTables
                   where o.Processed == false
                   select o;
 
          return View(BuyOffersTables);
      }
    

7 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 18 Aug 2011, 06:34 AM
Hi David,

 This is indeed strange. Could you please check with the debugger if the Count() of BuyOffersTables is the same in both action methods?

Regards,
Atanas Korchev
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items

0
David
Top achievements
Rank 1
answered on 18 Aug 2011, 02:37 PM
Hello,
i get all 3 responses on a refresh now but I had to change my code to:
    <% Html.Telerik().Grid<BuyOffersTable>()
        .BindTo(Model)
        .DataKeys(datakeys => datakeys.Add(c => c.BuyOfferGUID))
        .DataBinding(dataBinding => dataBinding.Ajax().Select("_BuyOffersTablesBinding", "BuyLetters"))
        .Name("BuyOffersTable")
        .Columns(columns =>
                    {
                        columns.Bound(o => o.BuyOfferGUID).Hidden(true);
                        columns.Bound(o => o.BuyOfferGUID)
                        .ClientTemplate("<a href='" + Url.Action("RequestDetails") + "/<#=BuyOfferGUID #>'>Select</a>")
                        .Template(o =>  {  %><%=Html.ActionLink("Select", "RequestDetails", new { id = o.BuyOfferGUID })%>});
 
                        columns.Bound(o => o.BuyOfferNumer)
                        .ClientTemplate("B<#=BuyOfferNumer #>")
                        .Template(o => { %>B<%=o.BuyOfferNumer%><% }).Title("Offer #");
                                                                                                                                              
                                                                                                                                              
                        columns.Bound(o => o.Createdate).Title("Created");
                        columns.Bound(o => o.FirstName).Title("First Name");
                        columns.Bound(o => o.LastName).Title("Last Name");
                    })
                    .Sortable()
                    .Scrollable()
                    .Pageable()
                    .Render();
 
%>


But there is still a problem with the first .template   with the actionlink command, at the point  new { id = o.BuyOfferGUID })%>});  the } when specifying the parameter for the actionlink your code thinks it is your end tag and writes out the following into the table

results from running code (select is indead a hyperlink)  in the first column:
Select}); columns.Bound(o => o.BuyOfferNumer) .ClientTemplate("B<#=BuyOfferNumer #>") .Template(o => { %>B9898

how is this line suposed to be properly formated:
columns.Bound(o => o.BuyOfferGUID)
.ClientTemplate("<a href='" + Url.Action("RequestDetails") + "/<#=BuyOfferGUID #>'>Select</a>")
.Template(o =>  {  %><%=Html.ActionLink("Select", "RequestDetails", new { id = o.BuyOfferGUID })%>});


0
Atanas Korchev
Telerik team
answered on 18 Aug 2011, 05:04 PM
Hello David,

 There is a missing <%

.Template(o =>  { 
  %>
        <%=Html.ActionLink("Select", "RequestDetails", new { id = o.BuyOfferGUID }) %>
   <%
  });

Regards,
Atanas Korchev
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items

0
David
Top achievements
Rank 1
answered on 18 Aug 2011, 06:05 PM
Oh boy...Thanks....  ok now I get all three lines on both both on ajax refresh this line is not printing the select url i want

.ClientTemplate("<a href='" + Url.Action("RequestDetails") + "/<#=BuyOfferGUID#>'>Select</a>")

instead it just skips the column on ajax refresh

Sorry guess I just to tired to work this week, but this looks ok to me.

0
Rosen
Telerik team
answered on 19 Aug 2011, 08:21 AM
Hi David,

Unfortunately, we are not sure what may be the cause for the issue you are facing judging from the provided details. Therefore, it will be appreciated if you could provided a small runnable sample where this behavior can be observed. 

Regards,
Rosen
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items

0
David
Top achievements
Rank 1
answered on 19 Aug 2011, 03:05 PM

by removing these two lines solves the problem


.DataKeys(datakeys => datakeys.Add(c => c.BuyOfferGUID))

columns.Bound(o => o.BuyOfferGUID).Hidden(true);

0
Atanas Korchev
Telerik team
answered on 22 Aug 2011, 10:11 AM
Hello David,

 Perhaps the reason was the hidden column. Hidden columns should be last otherwise Internet Explorer may fail to display them properly.

Regards,
Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
David
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or