<section> @(Html.Kendo().Window() .Modal(true) .Name("window") .Height(200) .Width(400) .Title("Case Documents") .Visible(false) .LoadContentFrom("Index", "Home") .Pinned(true) ) <a id="openButton">Open Window</a>// this works when the page is loaded $(function () { $("#window").data("kendoWindow").center().open(); });// this does not work, even if I remove the above code, it says $(...).data(...) is undefined $($("#openButton").click(function () { $("#window").data("kendoWindow").center().open(); }));Hi, I need to send in a bunch of form values to the create method (add new button) on the grid.
For edit, I used like this and it works fine.
grid call:
.Read(read => read.Action("Read_FinesByMLS", "FinesHistoryByMLS").Data("ParameterData"))
js function:
function ParameterData() {
alert("para=" + $("#MLSNumber").val());
return {
MLSNumber: $("#MLSNumber").val()
}
}
controller function:
public ActionResult Read_FinesByMLS([DataSourceRequest] DataSourceRequest request, string MLSNumber)
{
using (var context = new MATRIXEntities_Connection ())
{
IQueryable<FineHistory> finebymls = context.FineHistories;
if (MLSNumber != null)
{
finebymls = finebymls.Where(f => f.MLSNumber == MLSNumber); }
DataSourceResult result = finebymls.ToDataSourceResult(request, f => new FineHistoryViewModel
{
FineHistoryId = f.FineHistoryId ,
FineCode = f.FineCode,
});
return Json(result);
}
}
When I tried to do same for create, I am not getting any value for the parameter in the controller function. MLSNumber param is coming null. Any help is appreciated. Thanks
here is my create action call.
.Create(create => create.Action("Create_FinesByMLS", "FinesHistoryByMLS").Data("ParameterData"))
Its the same function call as above for edit function.
Controller function.
public ActionResult Create_FinesByMLS([DataSourceRequest] DataSourceRequest request, string MLSNumber) { using (var objFines_Context = new MATRIXEntities_Connection()) { */ //objFines_Context.usp_InsertFineHistory("211131297", "479", 4790, "713779DAF4844A", "239024", "281530", "kmantrip", "M"); //objFines_Context.SaveChanges(); } return View(); }the parameter is
@(Html.Kendo().Grid<KendoTest2.Models.DocumentType>() .Name("grid") .DataSource(dataSource => dataSource // Configure the grid data source .Ajax() // Specify that ajax binding is used .Read(read => read.Action("Products_Read", "Home")) // Set the action method which will return the data in JSON format ) .Columns(columns => { // Create a column bound to the ProductID property columns.Bound(product => product.Id); // Create a column bound to the ProductName property columns.Bound(product => product.Name); // Create a column bound to the UnitsInStock property }) .Pageable() // Enable paging .Sortable() // Enable sorting)public ActionResult Products_Read([DataSourceRequest]DataSourceRequest request) { using (var northwind = new MMCC_DocumentManagementEntities()) { IQueryable<DocumentType> products = northwind.DocumentTypes; DataSourceResult result = products.ToDataSourceResult(request); return Json(result); } }My grid column is:columns.Bound(r => r.RagStatus).EditorTemplateName("RAGStatus");Enum is:public enum RAGStatus{ Red = 1, Amber = 2, Green = 3,}public static List<SelectListItem> EnumToSelectList(Type enumType){ return Enum .GetValues(enumType) .Cast<int>() .Select(i => new SelectListItem { Value = i.ToString(), Text = Enum.GetName(enumType, i), } ) .ToList();}Enum template is:@model int@( Html.Kendo().DropDownListFor(m => m) .BindTo(EnumToSelectList(typeof(RAGStatus)).ToList()) .OptionLabel(optionLabel: "Please Select") .SelectedIndex(0))