Hi, I have the following grid:
@(Html.EJ().Grid<SlimHub.Models.WorkLocation>
("LocationsGrid")
.Datasource(ds => ds.Json((IEnumerable<WorkLocation>
)Model.WorkLocations.ToList()).UpdateURL("../NormalLocationUpdate").InsertURL("../NormalLocationInsert").RemoveURL("../NormalLocationDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit =>
{
edit.AllowAdding().AllowDeleting().AllowEditing();
})
.Locale("it-IT")
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.AllowResizing()
.AllowSorting()
.SortSettings(sort => { sort.SortedColumns(col => { col.Field("AreaId").Direction(SortOrder.Ascending).Add(); col.Field("Prog").Direction(SortOrder.Ascending).Add(); }); })
.AllowFiltering()
.FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
.AllowGrouping()
.GroupSettings(group => { group.GroupedColumns(col => { col.Add("AreaId"); }); })
.PageSettings(page => { page.PageSize(20); })
.AllowTextWrap(true)
.Columns(col =>
{
col.Field("WorkLocationId").HeaderText("ID Riga Rilevamento Lavoro").HeaderTextAlign(TextAlign.Center).IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(5).Visible(false).Add();
col.Field("WorkId").DefaultValue(@Model.WorkId).HeaderText("ID Lavoro").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(5).Visible(false).Add();
col.Field("LocationId").HeaderText("Postazione").ForeignKeyField("LocationId").ForeignKeyValue("LocationCode").DataSource((IEnumerable<object>)ViewBag.ContractLocations).HeaderTextAlign(TextAlign.Center).Width(10).Add();
col.Field("EquipmentDesc").HeaderText("Attrezzatura").HeaderTextAlign(TextAlign.Center).AllowEditing(true).Width(10).Add();
col.Field("IsCapture").HeaderText("Cattura").HeaderTextAlign(TextAlign.Center).AllowEditing(true).Width(10).Add();
//col.Field("LocationId").HeaderText("Cattura").ForeignKeyField("LocationId").ForeignKeyValue("IsCapture").DataSource((IEnumerable<object>)ViewBag.LocationsData).HeaderTextAlign(TextAlign.Center).Width(10).Add();
col.Field("AreaId").HeaderText("Area").ForeignKeyField("AreaId").ForeignKeyValue("AreaDescription").DataSource((IEnumerable<object>)ViewBag.Areas).HeaderTextAlign(TextAlign.Center).Width(10).Add();
col.Field("Prog").HeaderText("Num. Post.").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Center).Width(10).Add();
col.Field("UnavailableLocation").HeaderText("Non Rev.").HeaderTextAlign(TextAlign.Center).EditType(EditingType.Boolean).TextAlign(TextAlign.Center).Width(10).Add();
//col.Field("LocationTypeCode").HeaderText("Tipo").ForeignKeyField("LocationTypeCode").ForeignKeyValue("LocationTypeDesc").DataSource((IEnumerable<object>)ViewBag.LocationTypes).HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Center).Width(10).Add();
col.Field("UsageValueCode").HeaderText("Riscontro").ForeignKeyField("UsageValueCode").ForeignKeyValue("UsageValueDesc").DataSource((IEnumerable<object>)ViewBag.UsageValues).HeaderTextAlign(TextAlign.Center).Template("<img style='width: 24px; height: 24px' src='../../images/UsageValues/{{:UsageValueCode}}.png' alt='{{:UsageValueCode}}.png' />").TextAlign(TextAlign.Center).Width(10).Add();
col.Field("IntVal1").HeaderText("Catture").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Center).Width(10).Add();
col.Field("LocationTag").HeaderText("Tag Postazione").HeaderTextAlign(TextAlign.Center).Width(30).Add();
col.Field("Annotations").HeaderText("Note").HeaderTextAlign(TextAlign.Center).Width(50).Add();
})
.ClientSideEvents(eve =>
{
eve.ActionComplete("complete").ActionBegin("LocationsGridActionBegin").EndEdit("endEdit").EndAdd("endAdd");
eve.QueryCellInfo("onQueryCelInfo");
eve.Load("onLoad");
eve.CellEdit("cellEdit");
})
)
When I chenge value on the LocationId column (dropdownlist), I would like to set values on two unbound columns.
I have used setCellText method but an error Cannot set property 'innerHTML' of undefined appears.
This is the javascript part:
function ValChange(e) {
var gridObj = $("#LocationsGrid").data("ejGrid");
gridObj.setCellText(0, 10, 'GREYER');
var index = gridObj.selectedRowsIndexes;
debugger;
$.ajax({
url: '../../Work/GetLocationMainData',
type: 'GET',
async: false,
data: { "LocationId": e.value },
dataType: 'json',
success: function (result) {
gridObj.setCellText(index, 3, result.EquipmentDesc);
}
})
}
</script>
How can I solve this problem?