@(Html.EJ().Grid<EducationDepartmentModel>("FlatGrid")
.Datasource(ds => ds.URL(Url.Action("EduDeptDataSource", "CRUD", null, Request.Url.Scheme)).BatchURL(Url.Action("EduDeptBatchUpdate", "CRUD", null, Request.Url.Scheme)).Adaptor(AdaptorType.UrlAdaptor))
.EnableAltRow()
.AllowFiltering()
.SelectedRowIndex(0)
.IsResponsive()
.AllowSorting()
.GridLines(GridLines.Horizontal)
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Batch); })
.PageSettings(page =>
{
page.PageSize(5);
})
.AllowTextWrap()
.AllowResizeToFit()
.EnableHeaderHover()
.FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
.AllowPaging()
.ClientSideEvents(eve =>
{
eve.ActionComplete("complete");
eve.ActionFailure("failure");
eve.RecordClick("recordClick");
eve.RecordDoubleClick("recordDoubleClick");
eve.ContextOpen("contextopen");
eve.ContextClick("contextclick");
eve.ActionBegin("beginAction");
eve.BeforeBatchAdd("beforeBatchAdd");
eve.CellEdit("cellEdit");
})
.Columns(col =>
{
col.Field(p => p.departmentId).HeaderText("Department ID").IsPrimaryKey(true).Visible(false).TextAlign(TextAlign.Left).Width(70).Add();
col.Field(p => p.educationId).HeaderText("Department ID").Visible(false).TextAlign(TextAlign.Left).Width(70).Add();
col.Field(p => p.departmentCode).HeaderText("Department Code").TextAlign(TextAlign.Left).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Width(70).Add();
col.Field(p => p.description).HeaderText("Description").Width(90).ValidationRules(v => v.AddRule("required", true).AddRule("maxlength", 40)).Add();
col.Field(p => p.budgetAmount).HeaderText("Budget Amount").EditType(EditingType.Numeric).Format("{0:C}").NumericEditOptions(new EditorProperties() { DecimalPlaces = 2 }).ValidationRules(v => v.AddRule("range", "[0,1000]")).Add();
col.Field(p => p.costIncurred).HeaderText("Cost Incurred").EditType(EditingType.Numeric).Format("{0:C}").NumericEditOptions(new EditorProperties() { DecimalPlaces = 2 }).ValidationRules(v => v.AddRule("range", "[0,1000]")).Add();
})
)
To open the popup dialog box , i am using this code -
function cellEdit(args){
if(args.columnName == "description"){
args.cancel = true;
}
if(args.columnName == "departmentCode"){
$("#helpDialog").ejDialog("open");
}
}
and this is my popup grid model -
@{Html.EJ().Dialog("helpDialog").Title("Cost Center Code").IsResponsive(true).ShowOnInit(false).ContentTemplate(@<div>
<form id="form1">
@(Html.EJ().Grid<DepartmentModel>("FlatGrid2").Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource2))
.AllowSelection()
.AllowTextWrap()
.EnableHeaderHover()
.EnableAltRow()
.AllowPaging()
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Search);
});
})
.PageSettings(page =>
{
page.PageSize(10);
})
.ClientSideEvents(eve =>
{
eve.RecordDoubleClick("select");
})
.Columns(col =>
{
col.Field(p => p.departmentCode).HeaderText("Department Code").IsPrimaryKey(true).Width(50).TextAlign(TextAlign.Left).Add();
col.Field(p => p.description).HeaderText("Department Description").TextAlign(TextAlign.Left).Width(90).Add();
})
)
</form>
</div>).EnableModal(true).EnableResize(false).ClientSideEvents(evt => evt.Close("onDialogClose")).IsResponsive(true).Render();}
as you can see , i have added recordDoubleClick event to get the selected row value-
function select(args) {
var result = this.getSelectedRecords();
var costCode = result[0].departmentCode;
var costDesc = result[0].description;
$("#helpDialog").ejDialog("close");
alert(args.value);
var gridInstance = $("#FlatGrid").ejGrid("instance");
var index = gridInstance.selectedRowsIndexes;
gridInstance.setCellText(index, "departmentCode", costCode);
gridInstance.setCellText(index, "description", costDesc);
}
when i use this code ,instead of setting the selected value to the cell , it creates a new textbox and set the selected value to it . Please guide me how to achieve this.