Is editing parent-child supported in CSLA MVC 4.3.10?

Is editing parent-child supported in CSLA MVC 4.3.10?

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


wilfreds posted on Monday, April 30, 2012

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

wilfreds replied on Wednesday, May 02, 2012

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>

JonnyBee replied on Wednesday, May 02, 2012

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

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

wilfreds replied on Wednesday, May 02, 2012

OK

Thanks.

TSF replied on Thursday, January 17, 2013

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.

Copyright (c) Marimer LLC