- Home
- Forum
- ASP.NET MVC
- Unable to set cell value in normal edit mode
Unable to set cell value in normal edit mode
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?
SIGN IN To post a reply.
1 Reply
PK
Prasanna Kumar Viswanathan
Syncfusion Team
July 19, 2017 09:05 AM UTC
Hi Claudio,
Thanks for contacting Syncfusion support.
We checked in our sample and the mentioned issue will reproduced when we use setCellText method for the cell which is in edited state. According to your requirement when you change the value in dropdownlist you need to set the cell value for other columns which is in same row. To achieve your requirement, use jQuery val method to set value for the input elements.
Find the code example:
|
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).UpdateURL("CellEditUpdate").------
---------------
.Columns(col =>
{
-----------------------
col.Field("EmployeeID").HeaderText("EmployeeName").ForeignKeyField("EmployeeID").ForeignKeyValue("FirstName").---
-----------------
})
.ClientSideEvents(eve => { eve.ActionComplete("complete"); })
)
<script type="text/javascript">
function complete(args) {
if (args.requestType == "beginedit") {
$(args.row[0]).find("select").ejDropDownList({ change: "ValChange" });
}
}
function ValChange(args) {
var gridObj = $("#FlatGrid").data("ejGrid");
$(gridObj.element.find(".gridform").find("td")[10]).find("input").val("DAMN");
}
</script> |
Regards,
Prasanna Kumar N.S.V
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
CR CLAUDIO RICCARDI
- Jul 18, 2017 04:25 PM UTC
- Jul 19, 2017 09:05 AM UTC