Hello Infragistics community,
I have made a little sample project to illustrate my problem. This is how the page looks like.
My model that I pass to the View is the class Company.
This is how my controller looks like (w/out the jquery script part...)=>
and my View looks like this.
I need to save the data from the company and from the employee table after clicking the "save" button. This has to be executed on one button click, since im doing some complex validations. I have no issuse saving the employee table, but i have problems saving the company attributes ( company name & company address).
Thank you very much
Hello,
In the screenshot provided, it looks like the input element is after the curly brace, I suggest putting it within the curly brace of the Html.BeginForm.
Please provide more information on how you are handling saving the data within the controller.
Hello Sam. Thank you for your reply. This is how the SaveData method in the controller looks like:
[HttpPost] public ActionResult SaveData() {
GridModel gridModel = new GridModel(); List<Transaction<Employee>> transactions = gridModel.LoadTransactions<Employee>...
(HttpContext.Request.Form["ig_transactions"]);
// here im getting the changes of the employee table. This works fine
//But how do I get the changes of my company?
foreach (Transaction<Employee> t in transactions) { //do something.. }
JsonResult result = new JsonResult(); Dictionary<string, bool> response = new Dictionary<string, bool>(); response.Add("Success", true); result.Data = response; return result; }
I tryed putting the input element inside the curly brackets of the form, but it didnt work.
This is how my complete view looks like:
<!-- Ignite UI Required Combined CSS Files --><link href="http://cdn-na.infragistics.com/igniteui/2016.1/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" type="text/css" /><link href="http://cdn-na.infragistics.com/igniteui/2016.1/latest/css/structure/infragistics.css" rel="stylesheet" type="text/css" />
<script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js" type="text/javascript"></script><script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script><script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js" type="text/javascript"></script>
<!-- Ignite UI Required Combined JavaScript Files --><script src="http://cdn-na.infragistics.com/igniteui/2016.1/latest/js/infragistics.core.js" type="text/javascript"></script><script src="http://cdn-na.infragistics.com/igniteui/2016.1/latest/js/infragistics.lob.js" type="text/javascript"></script><!-- Used to add modal loading indicator for igGrid --><script src="http://www.igniteui.com/js/grid-modal-loading-inicator.js"></script>
@using Infragistics.Web.Mvc@model WebApplication1.Models.Company@{ ViewBag.Title = "Index";}<h2>Edit - Company</h2>@using (Html.BeginForm()){ @Html.AntiForgeryToken() <div class="form-horizontal"> <hr /> <div class="form-group"> @Html.LabelFor(model => model.CompanyName, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.CompanyName, new { htmlAttributes = new { @class = "form-control" } }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.Address, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.Address, new { htmlAttributes = new { @class = "form-control" } }) </div> </div> </div> <hr /> <hr /> <h2>Employee List</h2> @(Html.Infragistics() .Grid(Model.EmployeeList).ID("Grid").Width("100%").Height("150px").PrimaryKey("ID") .AutoGenerateColumns(false).AutoGenerateLayouts(false).EnableHoverStyles(false) .Columns(column => { column.For(x => x.FirstName).HeaderText("First Name").Width("40%"); column.For(x => x.LastName).HeaderText("Last Name").Width("40%"); }) .Features(features => { features.Updating().ColumnSettings(cs => { }).EnableAddRow(false).EnableDeleteRow(false); }) .UpdateUrl(Url.Action("SaveData")) .DataBind() .Render() ) <input type="button" id="saveChanges" class="button-style" value="Save" />}
<script> var updates, loadingIndicator;
$(function () { var grid = $("#Grid"), comboDataSource = {}; $("#saveChanges").igButton({ labelText: $("#saveChanges").val(), disabled: false }); loadingIndicator = new GridModalLoadingIndicator(grid);
$("#saveChanges").on('igbuttonclick', function (e) {
grid.igGrid("saveChanges", function saveSuccess() { loadingIndicator.hide(); }); loadingIndicator.show(); return false; } ); });
</script>