0

I have a webgrid that works fine

@{
                    var DB = Database.Open("CHAVI");
                    var grid = new WebGrid(DB.Query("SELECT [FileTrackingTag], FileID FROM (SELECT [FileTrackingTag], FileID, ROW_NUMBER() OVER (PARTITION BY [FileTrackingTag] ORDER BY FileID) rn FROM [dbo].[MasterSequence]) t WHERE rn=1 ORDER BY [FileTrackingTag]"));
                    @grid.GetHtml(
                        tableStyle: "webgrid",
                        columns: grid.Columns(
                            grid.Column(header: "Assign? ", style: "labelcolumn",
                                    format:
                                        @<text><input class="check-box" id="assignChkBx" name="assignChkBx" type="checkbox" value="@item.FileTrackingTag" /></text>),
                            grid.Column("FileTrackingTag", "FileTrackingTag")
                            )
                    )
                 }

However when I check off multiple boxes when I go between different tabs on the WebGrid, only the ones on the current tab get sent over (It is still the same webpage, it is just tabbing through the entries of the webgrid)

Is there a solution to keep them between webgrid tabs?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Badmiral
  • 1,549
  • 3
  • 35
  • 74
  • You might need to look into using something like signalR to synchronize between different browsers viewing the same page. – nieve Oct 30 '12 at 13:28
  • This is one page, where I cycle through the contents of the WebGrid – Badmiral Oct 30 '12 at 13:31
  • 1
    I have edited your title. Please see, "[Should questions include “tags” in their titles?](http://meta.stackexchange.com/questions/19190/)", where the consensus is "no, they should not". – John Saunders Oct 30 '12 at 14:12

1 Answers1

1

I am not aware of any built-in way to accomplish what you're talking about. WebGrid paging works by only selecting the data which needs to be displayed at a given time. If you look at your generated HTML for the web page, you'll see that only the "current" items are there.

Since the data for the other pages is not even in your web page, MVC has no way to know about them. Your best option is really to create an action on your controller and post the current items whenever the page is changed on the grid. You would store those posted items in some temporary storage (a cache, TempData, etc). Then, when the user clicks Save, you'll need to save both the items posted to your Save method and the ones from your temporary storage collection.

Before going all the way down this route, I'd double-check with the end users and make sure it's what they really want and expect. It takes a decent amount of work to implement correctly, and it might lead to some conclusion when you're updating records that they can't actually see on the screen. Other options would be to disable paging and use a different control, or use some type of wizard flow to make it clear that you're saving results after each "page".

Tim Copenhaver
  • 3,282
  • 13
  • 18