public ActionResult PerformUpdate([FromBody]CRUDModel<Orders> value)
{
. . .
. . .
}
public class Orders {
public int id { get; set; }
public DateTime dateCreate { get; set; }
public string actions { get; set; }
} |
Ok, I got the Update to work, however on INSERT the param value is always null.
public ActionResult PerformUpdate([FromBody]CRUDModel<cvLog> param)
{
dbContextPsMisc db = new dbContextPsMisc();
var rec = param.Value;
var val = db.cvLogs.Where(x => x.Id == rec.Id).FirstOrDefault();
//lookup original record and only change input fields
val.Actions = rec.Actions;
val.DateCreated = rec.DateCreated;
db.SaveChanges();
return Json(param.Value);
}
public ActionResult Insert([FromBody]CRUDModel<cvLog> param)
{
param.Value.Id = Guid.NewGuid();
using (var db = new dbContextPsMisc())
{
db.Add(param.Value);
}
return Json(param.Value);
}
<ej-grid id="Grid" allow-paging="true" allow-sorting="true" allow- allow-resize-to-fit="true" allow-searching="true" action-complete="complete">
<e-datamanager json="Model" update-url="PerformUpdate" insert-url="Insert" remove-url="DeleteUrl" adaptor="remoteSaveAdaptor"></e-datamanager>
<e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" edit-mode="InlineFormTemplate"
inline-form-template-id="#template" ></e-edit-settings>
<e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string> {"add","edit","delete","update","cancel","search"}' />
<e-columns>
<e-column field="Id" is-primary-key="true" header-text="Id" visible="false"></e-column>
<e-column field="DateCreated" header-text="Date Created" format="{0:MM/dd/yyyy}" text-align="Left" width="120"></e-column>
<e-column field="Actions" text-align="Left"></e-column>
<e-column field="AccountId" visible="false"></e-column>
</e-columns>
</ej-grid>
@section Scripts {
<script id="template" type="text/template">
<input type="hidden" id="Id" name="Id" value="{{: Id}}" />
<table cellspacing="10">
<tr>
<td>Date Created</td>
<td style="text-align: left">
<input id="DateCreated" name="DateCreated" value="{{: DateCreated}}" class="form-control" style="width:116px;height:28px" />
</td>
<td>Action</td>
<td style="text-align: left; width: 300px">
<input id="Actions" name="Actions" value="{{: Actions}}" class="form-control"
style="width: 300px; height: 28px" />
</td>
</tr>
</table>
</script>
<script>
function complete(args) {
$("#DateCreated").ejDatePicker({ dateFormat: "MM/dd/yyyy" });
}
</script>
<ej-grid id="FlatGrid" allow-paging="true">
<e-columns>
<e-column field="OrderID" is-identity="true" is-primary-key="true" visible="false" text-align="Right" width="75"></e-column>
. . .
</e-columns>
</ej-grid>
|