Build: 2012.3.1413
When my batch grid is saved, I am trying to add items to a list property that is present on the grid's dataSource. I am getting an accurate quantity of items inserted into this list property, but I am not getting any of the data that should be present with it. The strange thing is that the values DO appear to be present when I use firebug to look at what is being sent to the server, but the data disappears on the object on the controller side (except for the appropriate number of entries)
ItemModel
ServiceModel
Script
DataSource state prior to grid sync() - From Firebug
See image below, but the 1 attribute that should be populated is RefServiceID, and it is.
Result on POST -from Firebug
See image below, but same as DataSource (ie. RefServiceID should be the only attribute populate in the sub list items and it is.
***Issue is possible here because the full path of the data in the list is written strangely, but I'm not sure if it is correct.
Full path to RefServiceID (after push function) is:
models[0].ServiceBookList[0][RefServiceID]
I figure it should look list other arrays and be like this (but not sure):
models[0].ServiceBookList[0].RefServiceID
Controller values
See Image Below
In case my description was insufficient, I have also included a screenshot of how everything is laid out in the application.
Please let me know if further code is needed. Also, I began this when there was no out of the box support for saving editable fields in a grid's detail template. Please let me know if this has changed and how I might go about doing it in a supported way.
Thanks!
When my batch grid is saved, I am trying to add items to a list property that is present on the grid's dataSource. I am getting an accurate quantity of items inserted into this list property, but I am not getting any of the data that should be present with it. The strange thing is that the values DO appear to be present when I use firebug to look at what is being sent to the server, but the data disappears on the object on the controller side (except for the appropriate number of entries)
ItemModel
public class ItemModel
{
public ItemModel()
{
ServiceBookList = new List<
ServiceModel
>();
}
public List<
ServiceModel
> ServiceBookList { get; set; }
}
public class ServiceModel
{
public ServiceModel() { }
public int RefServiceID { get; set; }
public string Value { get; set; }
public string Code { get; set; }
public long EnterpriseProductServiceBookID { get; set; }
public long AppUserProductServiceBookID { get; set; }
public bool IsDeleted { get; set; }
}
function SaveProductBook() {
//This is called when the "Save" button on the parent grid is clicked
var productBook = $("#AdminProductBookGrid").data("kendoGrid");
SaveProductDetailViews(productBook); //Save items located in detail template
productBook.dataSource.sync();
}
function SaveProductDetailViews(itemGrid) {
//For each row in grid, grab the latest data from the fields within the detail templates
//and update the row's dataSource prior to sync
$.each($("#AdminProductBookGrid tbody tr"), function (index, row) {
var dataItem = itemGrid.dataItem(row);
var detailRow = $(row).next();
if (dataItem != null && detailRow.has('.k-detail-cell').length > 0) {
SaveServiceDetailViews(dataItem, detailRow, type);
}
});
}
function SaveServiceDetailViews(dataItem, detailRow, type) {
var serviceGrid = $(detailRow).find("div[id=ServiceGrid_" + dataItem.uid + "]").data("kendoGrid");
//data is the item's added in the detail template's grid for that parent row
var data = serviceGrid.dataSource._data;
for(var i = 0; i < data.length; i++) {
//Add to the parent row's dataSource list
dataItem.ServiceBookList.push(data[i]);
}
}
See image below, but the 1 attribute that should be populated is RefServiceID, and it is.
Result on POST -from Firebug
See image below, but same as DataSource (ie. RefServiceID should be the only attribute populate in the sub list items and it is.
***Issue is possible here because the full path of the data in the list is written strangely, but I'm not sure if it is correct.
Full path to RefServiceID (after push function) is:
models[0].ServiceBookList[0][RefServiceID]
I figure it should look list other arrays and be like this (but not sure):
models[0].ServiceBookList[0].RefServiceID
Controller values
See Image Below
In case my description was insufficient, I have also included a screenshot of how everything is laid out in the application.
Please let me know if further code is needed. Also, I began this when there was no out of the box support for saving editable fields in a grid's detail template. Please let me know if this has changed and how I might go about doing it in a supported way.
Thanks!