I have popup edit mode enabled for my grid. Instead of using the native edit command button, I implemented row click to fire the edit command.
This works and the popup with my custom template shows. However, when I make changes to the data and click the Update button, the window closes, but the data doesn't get updated. My action in the controller is never hit. I then tried attaching to the Save event then calling a javasript method, but not sure how to persist data from there.
@section Scripts{
<script type=
"text/javascript"
>
function
onChange(e) {
var
grid = e.sender;
var
currentDataItem = grid.dataItem(
this
.select());
grid.editRow(currentDataItem);
}
function
onSave(e) {
var
grid = e.sender;
var
currentDataItem = grid.dataItem(
this
.select());
alert(currentDataItem[
"Details"
]);
// what to do here to persist changes??
}
</script>
}
@Html.Kendo().Grid(Model.Notes).Name(
"PermitNotes"
).DataSource(dataSource => dataSource.Ajax().Model(model => model.Id(
"LCARSKey"
))
.Update(update => update.Action(
"PermitNotes_Update"
,
"Permits"
))
.Read(read => read.Action(
"Sorting_PermitNotes_Read"
,
"Permits"
))
.Destroy(update => update.Action(
"PermitNotes_Delete"
,
"Permits"
))
.Create(create => create.Action(
"PermitNotes_Create"
,
"Permits"
))).Columns(columns =>
{
columns.Command(cmd => { cmd.Destroy(); }).Width(
"50px"
);
columns.Bound(p=>p.Details);
columns.Bound(p => p.Name).Title(
"User"
);
columns.Bound(p => p.DateCreated).Title(
"Date"
);
}).Sortable(sortable => sortable.AllowUnsort(
false
)).Selectable(selectable => selectable.Mode(GridSelectionMode.Single).Enabled(
true
)
.Type(GridSelectionType.Row)).ToolBar(toolbar => {toolbar.Custom().Text(@Html.IconEmoji(
"arrowLeft1"
).ToString()).Url(
"javascript:window.history.back();"
).HtmlAttributes(
new
{title=
"Go Back."
}); toolbar.Create().Text(
"Add New Note"
).IconClass(
""
).HtmlAttributes(
new
{hexkey=@Model.LcarsPermit.ObjectKey.ToHexKey()});
}).Editable(e=> { e.Mode(GridEditMode.PopUp);e.TemplateName(
"PermitNote"
);e.Enabled(
true
);}).Events(ev=> { ev.Change(
"onChange"
);
ev.Save(
"test"
);
})
Here is my custom template, only only one input
<
html
><
head
> <
meta
name
=
"viewport"
content
=
"width=device-width"
/> <
title
>PermitNote</
title
> <
style
type
=
"text/css"
> A.k-primary {
color: #FFF !important;
}
</
style
></
head
><
body
> <
div
class
=
"m-3"
> <
div
class
=
"float-left mr-2"
>Details: </
div
> <
div
class
=
"float-left"
>@Html.TextArea("Details", new { style = "width:250px;", rows = "3", cols = "100" })</
div
> </
div
></
body
></
html
>
I have a Grid with a custom popup editor. Inside the popup editor, I have a MultiColumnComboBox.
When I select a value in the MultiColumnComboBox and click Update button in the editor, the Update method does not get fired. When I console out e.model on the save event, dirty flag is false, dirtyFields is empty and contact_id is null.
@Html.LabelFor(model => model.contact_id)
@(Html.Kendo().MultiColumnComboBoxFor(model => model.contact_id)
.AutoBind(
false
)
.Placeholder(
"Select Contact..."
)
.DataTextField(
"contact_number"
)
.DataValueField(
"id"
)
.Columns(columns =>
{
columns.Add().Field(
"contact_number"
).Title(
"Id"
);
columns.Add().Field(
"contact_name"
).Title(
"Name"
);
})
.Filter(FilterType.Contains)
.DataSource(source =>
{
source.Read(read =>
{
read.Action(
"SearchContact"
,
"Manager"
).Data(
"getContactData"
).Type(HttpVerbs.Post);
})
.ServerFiltering(
false
);
})
)
I am pretty new to MVC/Telerik and am having an issue populating a grid. I created the standard Telerik MVC5 project with the Grid and menu. I added my model, created a context and updated the controllers and views. When i run the app on the Visual Studio IIS Express instance i have zero issues. However, once i publish it to an IIS 8 test server i receive HTTP 500 errors and an empty grid.Looking at the Fiddler results it appears that the read function on grid is the issue.
Grid Controller
public partial class GridController : Controller
{
public ActionResult Orders_Read([DataSourceRequest]DataSourceRequest request)
{
using (var ctx = new CWDataContext())
{
IQueryable<CWDataModel> carts = ctx.CW_Data;
DataSourceResult result = carts.ToDataSourceResult(request);
return Json(result);
}
}
}
Home Controller
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}
}
Model
[Table("CWCartLblFile")]
public class CWDataModel
{
[Key]
public int Row_ID { get; set; }
public string COLOR { get; set; }
public string SKU { get; set;
}
Context
public class CWDataContext : DbContext
{
public CWDataContext() : base("defaultString")
{
}
public DbSet<CWDataModel> CW_Data {get; set;}
}
Index View
<div class="row">
<div class="col-12">
@(Html.Kendo().Grid<TelerikMvcApp1.Models.CWDataModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(product => product.COLOR).Width(50);
columns.Bound(product => product.SKU).Width(50);
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.HtmlAttributes(new { style = "height:550px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("Orders_Read", "Grid"))
)
)
</div>
</div>
I am not sure if something in the code is incorrect or i overlooked something on the web server.
After upgrading to UI for ASPNET MVC 2019.2.619, default values defined in the grid's datasource section are no longer populating. This was working in a previous version. Now when clicking the new button, the fields are blank. Below is just an example. No code was changed from the previous version. This is for pop-up editing with a template. Any help would be appreciated.
.Model(model =>
{
model.Id(m => m.TruckKey);
model.Field(f => f.DriverName).DefaultValue("Driver Name");
})
Hi,
I have a standard grid with a NumericTextBoxFor field using inline editing in a MVC5 project.
The NumericTextBoxFor is configured to show 5 digits after the decimal separator in both the editor-template and the HTML code.
The problem is, that the 5 digits is only shown if the NumericTextBoxFor is selected when in edit mode or if not in edit mode at all - otherwise only 2 rounded digits is shown.
Any idea ?
I have a proof-of-concept to show, if this is new to you.
Thank you in advance.
Hello
I am searching for example usage of the Telerik controls to create a user interface for a one-to-many relationship.
For example, a form for an Invoice; and the lower portion of the form has a grid for the user to create multiple line items.
This is a common UI, but I'm unable to find anything. Any help is appreciated.
Thanks!
Hi
I am having an issue with the grid. I am using GridEditMode.PopUp. If I click create to open the PopUp and then press cancel, it inserts a blank row into the grid
Before version 2019.2 I used MobileSwitch for checkboxes and when I want to clear a form I did this:
1.
_form.reset();
2.
$(_form).find(
"[type=checkbox]"
).each(
function
() {
3.
$(
"#"
+
this
.id).data(
"kendoMobileSwitch"
).refresh();
4.
})
Now, using Switch, I've changed line 3 to
$(
"#"
+
this
.id).data(
"kendoSwitch"
).refresh();
but that didn't work.
How can I achieve the same with new Switch?
Hello,
I am new to MVC and Telerik. I am trying to devise a way to globally change themes (both those that come with Kendo in the C:\Program Files (x86)\Progress\Telerik UI for ASP.NET MVC R2 2019\styles folder and ones created via the SASS Theme builder.
I see the "Change Themes" drop down list at: https://demos.telerik.com/aspnet-mvc/dropdownlist
and the https://docs.telerik.com/kendo-ui/styles-and-layout/change-themes-on-the-client
but I am curious as to how we would go about creating a dynamic list of all the themes that come with Telerik and all user created sass themes and apply them globally for a user AND be able to save that theme so it is loaded for a user and applied every time they visit the site and the ability to change the theme and save
that preference at anytime. Thoughts?
Thanks,