Hi,
We are building a webapplication using the Web Client Software Factory Model-View-Presenter pattern.
We would like to take advantage of the Telerik control library, but we cannot find any samples on how to implement this properly in the MVP pattern using the ObjectContainerDataSource. This is what we would like to do:
1. One page with two RadGrids - in a multipage with a pageview for each grid.
2. The page containing the grids have a save button - when clicking this, the data from the grids should be saved. We don't want a save button for each grid, since this is not very user-friendly.
This is how we have done so far:
1. Insert a RadGrid like this:
2. Declare an ObjectContainerDataSource like this:
3. We display the grid in edit mode like this:
This makes all the rows in the grid editable when the page is loaded, and when the user clicks the "global" save button, we want to retrive the list of objects that was initially bound to the grid like this:
So, we want our save button event-handler do look something like this:
Is this even possible with the ObjectContainerDataSource or does it only allow updating on row at a time, with "Update" and "Cancel" option on each row? Which is not vey usefull in real-world applications.
Please let me know if I should provide more code to clarify what we want to do
We are building a webapplication using the Web Client Software Factory Model-View-Presenter pattern.
We would like to take advantage of the Telerik control library, but we cannot find any samples on how to implement this properly in the MVP pattern using the ObjectContainerDataSource. This is what we would like to do:
1. One page with two RadGrids - in a multipage with a pageview for each grid.
2. The page containing the grids have a save button - when clicking this, the data from the grids should be saved. We don't want a save button for each grid, since this is not very user-friendly.
This is how we have done so far:
1. Insert a RadGrid like this:
| <tel:RadGrid ID="gridKnuder" AutoGenerateColumns="false" |
| DataSourceID="ocdsKnuder" AllowPaging="True" AllowSorting="True" AllowMultiRowEdit="true" |
| AllowAutomaticUpdates="true" GridLines="None" Skin="Office2007" |
| OnPreRender="GridKnuder_PreRender" OnItemCreated="GridKnuder_ItemCreated" runat="server"> |
| <MasterTableView DataKeyNames="Kode" EditMode="InPlace" CommandItemDisplay="None"> |
| <Columns> |
| <tel:GridBoundColumn ReadOnly="true" UniqueName="ShowType" HeaderText="Type" DataField="TypeBeskrivelse" /> |
| <tel:GridBoundColumn HeaderText="Pris" UniqueName="ShowPris" DataField="Pris" /> |
| </Columns> |
| </MasterTableView> |
| </tel:RadGrid> |
2. Declare an ObjectContainerDataSource like this:
| <wcsf:ObjectContainerDataSource ID="ocdsKnuder" DataObjectTypeName="Niras.DasVaerdi.Entity.KKnudeStandardVaerdi" runat="server" /> |
3. We display the grid in edit mode like this:
| protected void GridKnuder_PreRender(object sender, System.EventArgs e) |
| { |
| if (!IsPostBack) |
| { |
| foreach (GridItem item in gridKnuder.MasterTableView.Items) |
| { |
| if (item is GridEditableItem ) |
| { |
| GridEditableItem editableItem = item as GridDataItem; |
| editableItem.Edit = true; |
| } |
| } |
| gridKnuder.Rebind(); |
| } |
| } |
| public IList<OurObject> Knuder |
| { |
| set { ocdsKnuder.DataSource = Session[skKnudeStandardVaerdier] = value; } |
| } |
So, we want our save button event-handler do look something like this:
| protected void Save(object sender, EventArgs e) |
| { |
| // Get the list of objects back from the grid or its datasource |
| IList<OurObject> vaerdier = gridKnuder.???????? or ocdsKnuder.???? |
| _presenter.OnKnuderUpdated(vaerdier); |
| Knuder = vaerdier; |
| } |
Is this even possible with the ObjectContainerDataSource or does it only allow updating on row at a time, with "Update" and "Cancel" option on each row? Which is not vey usefull in real-world applications.
Please let me know if I should provide more code to clarify what we want to do