Trying to Use One DataSource for ReadOnly List with Details Page Update

Trying to Use One DataSource for ReadOnly List with Details Page Update

Old forum URL: forums.lhotka.net/forums/t/5902.aspx


andrewrajcoomar posted on Sunday, November 30, 2008

I am a brand new user of this framework (excellent, excellent work Rocky). In addition, am writing my first Windows app having worked exclusively on web before.

Hoping someone can point me here. This is my situation:

I have some reference data tables that are very small (< 100 rows) and have a requirement to load all the records when the form load. My UI consists of TabControl control with two pages. Page1 contains a grid and Page2 is the Details page. The Grid is readonly. When a row selection is made from the grid, Page2 receives focus and data should be updatable. No deletes are allowed. Also, Page2 should allow for new data to be added.

I am binding the grid like this:

Me.ChartFieldOverrideListBindingSource.DataSource = New SortedBindingList(Of ChartFieldOverrideInfo)(chartFieldOverrideList)

ChartFieldOverrideList inherits from ReadOnlyListBase

Is this the correct approach for such an implementation? Ideally, when the user interacts with the data on Page2, just one record should be affected at a time. Going this way, it seems I will have to call Save manually, and handle a single row update. I am having crazy thoughts of using the row to populate my ChartFieldOverride object, and then call my methods from within that class to insert/update the row. Another thought I have it to bind Page2 to the single object class ChartFieldOverride and then call Fetch each time a selection is made from Page1. But then I'd have to Fetch on Page1 also, to refresh, when a new record is added via Page2. This all seems like a lot of traffic.

It appears, the whole workup looks like the Edit Project task in Project Tracker, except that I have the two forms combined into one.

Please, any advise.

Thanks, Andrew:

RockfordLhotka replied on Monday, December 01, 2008

You have perhaps three options (with various sub-options).

  1. Make ChartFieldOverrideList an editable list, so you can edit its items and call Save() on the whole list.
  2. Make ChartFieldOverrideList a dynamic list (inherit from EditableRootListBase), so you can edit its items an save each one individually (by calling SaveItem() on the list).
  3. Make ChartFieldOverrideList a read-only list, then use an editable root to edit each item as the user selects it
    1. After the editable root has been saved
      1. reload the ChartFieldOverrideList entirely - which will get not only your edit, but other user's edits too
      2. call a method on ChartFieldOverrideList to merge in the new data from the editable root (assuming the editable root contains all data required to populate an item in the list) (this won't catch changes from other users)
      3. call a method on ChartFieldOverrideList to have it use a Command object to reload the new data for the one item that you know has changed (this won't catch changes from other users)

 

andrewrajcoomar replied on Monday, December 08, 2008

Thanks Rocky.

I went with a combination of 2; readonlylist from which the user can select/delete, and then I use the selection to return a businessbase object.

However, I now have another issue, which I have posted here:

http://forums.lhotka.net/forums/post/28983.aspx

When I am adding new data I bind to a new basebusiness object thru a click event. The issue is, any textbox that I enter a value into requires a double-tab for me to exit it. This behaviour is not the same for edits, for which I am again binding to the same base business object, except that the GetMyData method was called, instead of NewData.

Really appreciate your help, sir.

Thanks,

Andrew

 

Copyright (c) Marimer LLC