I am using asp.net mvc grid with server wrappers and have 4 cascading dropdowns by utilizing custom editors. I am using inline editing with the grid. The grid is ajax and the dropdowns also get their data via ajax/json.
I am experiencing 2 symptoms which may or may not be related to the same problem:
1) When a change is made to the first dropdown, it's value is updated correctly in the database but the grid does not refresh. I found this article but it didn't correct my issue. Simply hitting refresh on the page shows the new/correct value.
2) The dropdowns are cascading correctly (ie when one is changed, the others get the correct choices). However, only the first dropdown (not the cascaded ones) are updated correctly in the database. The other's values are not updated.
Here's the Controller code that does the update:
Here's the grid cshtml:
Here's custom editor along with javascript:
I am experiencing 2 symptoms which may or may not be related to the same problem:
1) When a change is made to the first dropdown, it's value is updated correctly in the database but the grid does not refresh. I found this article but it didn't correct my issue. Simply hitting refresh on the page shows the new/correct value.
2) The dropdowns are cascading correctly (ie when one is changed, the others get the correct choices). However, only the first dropdown (not the cascaded ones) are updated correctly in the database. The other's values are not updated.
Here's the Controller code that does the update:
01.
public
ActionResult UpdateUnitListItemViewModel([DataSourceRequest] DataSourceRequest request, UnitListItemViewModel unitListItemViewModel)
02.
{
03.
if
(ModelState.IsValid)
04.
{
05.
// Map a unit and save it
06.
Unit unit = UnitRepository.GetUnit(unitListItemViewModel.UnitID);
07.
08.
unit.Property.StatusID = unitListItemViewModel.PropertyStatusID;
09.
unit.Property.SubStatusID = unitListItemViewModel.PropertySubStatusID;
10.
11.
unit.StatusID = unitListItemViewModel.UnitStatusID;
12.
unit.SubStatusID = unitListItemViewModel.UnitSubStatusID;
13.
14.
15.
PropertyRepository.Update(unit.Property, LoggedInUser.UserID);
16.
UnitRepository.Update(unit, LoggedInUser.UserID);
17.
18.
}
19.
return
Json(
new
[] { unitListItemViewModel }.ToDataSourceResult(request, ModelState));
20.
21.
}
01.
@(Html.Kendo().Grid<
ARPS.OpsPortal.Models.UnitListItemViewModel
>()
02.
.Name("Grid")
03.
.DataSource(datasource => datasource
04.
.Ajax()
05.
.Group( group => group.Add(c => c.MarketName))
06.
.Sort( sort => sort.Add("FormattedAddress").Ascending())
07.
.Read(read => read.Action("GetUnitListItemViewModels", "Property"))
08.
.Update(update => update.Action("UpdateUnitListItemViewModel","Property"))
09.
.Model(model => model.Field(p => p.FormattedAddress).Editable(false))
10.
.Model(model => model.Field(p => p.Name).Editable(false))
11.
.Model(model => model.Id(u => u.UnitID))
12.
)
13.
.Columns(columns =>
14.
{
15.
columns.Bound(u => u.FormattedAddress).Title("Address");
16.
columns.Bound(u => u.Name).Title("Unit");
17.
columns.Bound(u => u.PropertyStatusName).Title("Property Status");
18.
columns.Bound(u => u.PropertySubStatusName).Title("Property Sub Status");
19.
columns.Bound(u => u.UnitStatusName).Title("Unit Status");
20.
columns.Bound(u => u.UnitSubStatusName).Title("Unit Sub Status");
21.
columns.Bound(u => u.AssignedUserInitials).Title("User");
22.
columns.Command(command => command.Edit());
23.
})
24.
.Editable(editable => editable.Mode(GridEditMode.InLine))
25.
.Pageable()
26.
.Sortable()
27.
)
01.
@(Html.Kendo().DropDownList()
02.
.Name("PropertySubStatusID")
03.
.HtmlAttributes(new { style = "width:150px" })
04.
05.
.DataTextField("Name")
06.
.DataValueField("StatusID")
07.
.DataSource(source => {
08.
source.Read(read =>
09.
{
10.
read.Action("GetActiveSubStatuses", "Status")
11.
.Data("filterPropertySubStatuses");
12.
})
13.
.ServerFiltering(true);
14.
})
15.
.Enable(true)
16.
.SelectedIndex(0)
17.
.AutoBind(false)
18.
.CascadeFrom("PropertyStatusID")
19.
20.
)
21.
22.
<
script
type
=
"text/javascript"
>
23.
24.
function filterPropertySubStatuses() {
25.
return {
26.
StatusID: $("#PropertyStatusID").val()
27.
};
28.
}
29.
30.
</
script
>