CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Is editing parent-child supported in CSLA MVC 4.3.10?

rated by 0 users
Answered (Not Verified) This post has 0 verified answers | 4 Replies | 1 Follower

Top 500 Contributor
27 Posts
wilfreds posted on Mon, Apr 30 2012 8:42 AM

I have looked in the USING CSLA 4 ASP MVC book.

The book talks about EditList View. But nothing about more complex views.

I am trying to make a view similar to editing an Order with order lines on the same screen.

Is that possible?

 

Regards,

Wilfred

All Replies

Top 500 Contributor
27 Posts

This is what I got so far. I can see the fields from OrderHead comming back. But the order rows list is empty.

Any suggestions?

Edit.cshtml:

 

@ using Csla.Web.Mvc
@ using Library

@model Library. ButOrderHead

@{
  ViewBag.Title = "Edit order" ;
}

< h2> @ViewBag.Title </ h2>

< script src ="@ Url.Content( "~/Scripts/jquery.validate.min.js" )" type ="text/javascript"></script >
< script src ="@ Url.Content( "~/Scripts/jquery.validate.unobtrusive.min.js" )" type ="text/javascript"></script >

@ using (Html.BeginForm())
{
  @ Html.ValidationSummary(true )
  <fieldset >
    <legend > Ordehead</ legend >
    @ Html.HiddenFor(model => model.BOHRec)
    @ Html.HiddenFor(model => model.BOHDateCreated)
    <div class="editor-label">
      @Html.LabelFor(model => model.Comid)
    </div >
    <div class="editor-field">
      @Html.HasPermission(Csla.Rules. AuthorizationActions.WriteProperty, Model, ButOrderHead .ComidProperty,
                             Html.EditorFor(model => model.Comid),
                             Html.DisplayFor(model => model.Comid))
      @Html.ValidationMessageFor(model => model.Comid)
    </div >
    @ if (((Csla.Security.IAuthorizeReadWrite )Model).CanWriteProperty( ButOrderHead.BOHFritekstProperty.Name))
    {
      < div class ="editor-label">
        @Html.LabelFor(model => model.BOHFritekst)
      </ div>
      < div class ="editor-field">
        @Html.EditorFor(model => model.BOHFritekst)
        @Html.ValidationMessageFor(model => model.BOHFritekst)
      </ div>
    }
    <div class="editor-label">
      @Html.LabelFor(model => model.BOHOrderDate)
    </div >
    <div class="editor-field">
      @Html.EditorFor(model => model.BOHOrderDate)
      @Html.ValidationMessageFor(model => model.BOHOrderDate)
    </div >
    <p >
      @Html.HasPermission(Csla.Rules. AuthorizationActions.EditObject, typeof (ButOrderHead ), @"<input type=""submit"" value=""Save"" />" , string.Empty)
    </p >
    <fieldset >
      < legend> Orderlines </legend >
      < table>
        < thead>
          < tr>
            < td>
              Itemline name
            </ td>
          </ tr>
        </ thead>
        < tbody>
          @for ( int i = 0; i < Model.ButOrderRows.Count; i++)
          {
            < tr>
              < td> @Html.EditorFor(r => Model.ButOrderRows[i ].Itmname)
              </ td>
            </ tr>
          }
        </ tbody>
      </ table>
    </fieldset >
  </fieldset >
}
< div>
  @ Html.ActionLink("Back to List" , "Index")
</ div>

Top 10 Contributor
1,770 Posts
Suggested by JonnyBee

This is already on the wish-list for Csla.Web.Mvc

http://www.lhotka.net/cslabugs/edit_bug.aspx?id=978

Jonny Bekkum, Norway CslaContrib Coordinator

Top 500 Contributor
27 Posts

OK

Thanks.

Top 50 Contributor
178 Posts
Tim replied on Thu, Jan 17 2013 10:35 PM

If this is still not available, what is the preferred way for updating children in this scenario?  How would I go about grabbing the property values for each of the child objects when updating the parent?  (The child list property on the parent isn't available in the model when the controller action is invoked.)  Do I need to use the FormsCollection or something like that?  Thanks.

Tim

Page 1 of 1 (5 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems