How can I make editable first 3 columns of telerik grid? I can make editable the whole row but I need only first 3 columns.
Thanks.
For some unknown reason I can't seem to get my EditTemplates to work if I have them in a folder named "EditorTemplates" in the same folder as my view containing the Kendo UI Grid (MVC) but if I put the same file in Shared/EditorTemplates it works. If I look at this example the Edit Template is setup as indicated above but is working (I guess).
https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/custom-popup-editor/KendoUIMVC5/Views/Home
What do I need to do to get it to work from an EditorTemplates folder in same folder as my main view?
I have a window (apologies for bolding... seems easiest way to distinguish code given limited formatting options)
@(Html.Kendo()
.Window()
.Name("UserPermissionsWindow")
.Title("User Privileges")
.Content("loading privlege settings...")
.Iframe(true)
.Draggable()
.Resizable()
.Visible(false))
opened by a button click from a grid row:
columns.Command(com => com.Custom("Privileges")
.Click("openUserPermissionsWindow"));
The click handler calls the window refresh button:
<script type="text/javascript">
function openUserPermissionsWindow(e) {
e.preventDefault();
// the dataitem retrieved here will have the field values that can subsitute in the template (I hope)
var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
personId = dataItem.Person_ID; //will this work?????
var wnd = $("#UserPermissionsWindow").data("kendoWindow");
wnd.refresh({
url: "UserPrivileges/" + personId, // what does this url need to look like?
data: { id: personId }
});
wnd.center().open();
}
</script>
And the action returns a partialview containing a treeview wrapper:
<b>yo 'sup?</b>
@( Html.Kendo()
.TreeView()
.DataTextField("Name")
.Name("userModulePermissions")
.Checkboxes(cbxConfig => cbxConfig.Enabled(true)
.CheckChildren(true)
.Name("checkedNodes"))
.DataSource(d => d.Read(read => read.Action("PermissionsTree_Read",
"SettingsUsers",
new {
userId = Model
})))
)
But I end up with javascript error: ReferenceError: jQuery is not defined
This is "fixed" by putting the jquery (and kendo?) bundles at the top of the PARTIAL view:
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/kendo")
But because this is a PartialView in a window on a page that already exists, shouldn't it be able to use the jquery library that is already on the page?
I don't think I should have to bundle jquery libraries on partial views.
Currently the jquery bundle is at top of layout page.
Please advise.
We are experiencing an issue with the Kendo ui datetime picker in our MVC Sitefinity application. The issue manifests itself only in IE after a workaround JavaScript function has been applied. The application's default culture is set to fr-CA however in the view the date format needs to be fr-FR. If submit is clicked and the text area of the datetime picker is empty the validation message as set on the model property is displayed correctly, however if any non valid text is entered into the text area then the validation message displayed is: "DateDebut is not a valid date". The workaround function replaces the data-val-date attribute displaying the correct validation message in the French language and as stated works in all browsers but IE. As show below the kendo culture is set to fr-FR.
$(document).ready(function () {
kendo.culture("fr-FR");
});
$(function () {
$("input[data-val-date]").each(function (index, el) {
var re = new RegExp("The field (.*?) must be a date");
var string = $(this).attr("data-val-date");
var m = string.match(re);
if (m != null && m.length > 1) {
$(this).attr("data-val-date", string.replace(m[0], "Le champ " + m[1] + " doit être une date (ex: 14/06/2015)"));
}
});
});
<
div
class
=
"form-group"
style
=
"width: 100%"
>
@Html.LabelFor(m=> m.DateDebut, new { @class = "control-label col-sm-4" })
<
div
class
=
"col-sm-3"
>
@Html.Kendo().DatePickerFor(m => m.DateDebut).Format("{0:dd/MM/yyyy}").HtmlAttributes(new {@style="width:150px;"})
@Html.ValidationMessageFor(m => m.DateDebut)
</
div
>
</
div
>
I am trying to use a JQuery command to call the Create action on a grid. Reason for this is that i need to pass an external id to the create command that is currently stored in a hidden HTML input field.
Here is the code
HTML
<
input
type
=
"hidden"
id
=
"acctid"
value
=
""
>
Script
function insertnotes(e) {
var accId = document.getElementById("acctid").value;
alert(accId);
$("#Child").data("kendoGrid").dataSource.create({ accountId: accId });
//$("#Child").data("kendoGrid").dataSource.read({ accountId: accId });
}
GRID
.Create(create => create.Action("Account_Master_Notes_Create", "AccountMaster"))
Action in Controller
public ActionResult Account_Master_Notes_Create(string acctid,
[DataSourceRequest]DataSourceRequest request, Account_Note_Master account_Notes_Master)
The alert in the script is telling me that acctid is populated... i just want to call the create action.... the error i am getting is that dataSource.create is not a function
Thanks for any help on this issue.
Corey
Hello
I have a scheduler with a custom edittemplate that sets the usual stuff like title, start, end and so on.
Furthermore my template contains a javascriptfunction for adding or subtracting workers from the event and storing the result in an array called taskOperators.
How do I pass that array to my controller action for create and update?
.DataSource(d => d
.Model(m =>
{
m.Id(f => f.TaskID);
m.Field(f => f.Color).DefaultValue("#cc99ff");
m.Field(f => f.Title);
m.RecurrenceId(f => f.RecurrenceID);
})
.ServerOperation(true)
.Read("Tasks_Read", "Home")
.Create("Task_Create", "Home")
.Destroy("Task_Delete", "Home")
.Update("Task_Update", "Home")
)
I saw something about adding .Data method to the .Update and .Create but how do I bind that to my Array taskOperators?
Best regards
Jonas
I occasionally see 404 Not Founds in our logs on the DejaVu fonts. I see they were added in Q3 2014 for PDFs but I am not using PDF exports. I do not have the fonts in the css/fonts folder since I did not think I needed them. The page does have a grid control.
Any idea on why these are being requested? I can't reproduce this so can't see the source to debug it. Of course one solution is to add the fonts to the project.
Thanks
Hi ! Im searching for a solution of my problem. Ich have a simple table named job with foreign keys from category and customer. I woultd like to edit this structure by using a listvew. My template is looking like:
<script type="text/x-kendo-tmpl" id="jobtemplate">
<div class="job-view k-widget">
<div class="edit-buttons">
<a class="k-button k-button-icontext k-edit-button" href="\\#"><span class="k-icon k-edit"></span></a>
<a class="k-button k-button-icontext k-delete-button" href="\\#"><span class="k-icon k-delete"></span></a>
</div>
<dl>
<dt>Info</dt>
<dd>#:Info#</dd>
<dt>Job-Category</dt>
<dd>#:Category.Name#</dd>
<dt>Customer</dt>
<dd>#:Customer.Name#</dd>
.....
But when I click on the "add new Job"- button I will get the javscript error "Uncaught ReferenceError: Category is not defined". When I'm using the grid this is able to work, but not in Listview. What I'm doing wrong?
best regards Andreas Laffer
@(Html.Kendo().Grid<
GMCWebApplication.Areas.admin.Models.UserGridModel
>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(c => c.Id).Hidden();
columns.Bound(c => c.UserFName).Title("First Name");
columns.Bound(c => c.UserLName).Title("Last Name");
columns.Bound(c => c.UserName);
columns.Bound(c => c.PasswordHash).Hidden();
columns.Bound(c => c.Email);
columns.Template(@<
text
></
text
>).ClientTemplate("<
input
type
=
'checkbox'
#= IsBIUser ?
checked
=
'checked'
:'' #
class
=
'chkbx'
/>").Width(100).Title("BI User");
columns.Bound(c => c.StartDate).Format("{0:MM/dd/yyyy}");
columns.Bound(c => c.EndDate).Format("{0:MM/dd/yyyy}");
columns.Bound(c => c.UserKey).Hidden();
})
.ToolBar(toolbar => toolbar.Save())
.Editable(ed => ed.Mode(GridEditMode.InCell))
.Sortable()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.Filterable()
.DataSource(dataSource => dataSource
.WebApi()
.Batch(true)
.Model(model => model.Id(c => c.Id))
.Read(read => read.Url("/api/gmcmembership/au/11712").Type(HttpVerbs.Get))
.Update(update => update.Url("/api/gmcmembership/uu").Type(HttpVerbs.Put))
)
)
/// <summary>
/// Updates user(s) in GMCMembership System with changes made in Kendo Grid
/// </summary>
/// <param name="users"></param>
/// <remarks> </remarks>
[System.Web.Http.HttpPut]
[System.Web.Http.Route(
"uu"
)]
public
HttpResponseMessage UpdateUsers([Bind(Prefix =
"models"
)]IEnumerable<UserGridModel> users )
{
try
{
using
(
var um =
new
UserManager<ApplicationUser>(
new
UserStore<ApplicationUser>(
new
ApplicationDbContext()))
)
{
foreach
(var user
in
users)
{
var id = user.Id;
var userToUpdate =
new
ApplicationUser();
userToUpdate = um.Users.SingleOrDefault(u => u.Id == id);
if
(userToUpdate !=
null
)
{
userToUpdate.Email = user.Email;
userToUpdate.EndDate = (DateTime)user.EndDate;
userToUpdate.IsBIUser = user.IsBIUser;
userToUpdate.StartDate = (DateTime)user.StartDate;
userToUpdate.UserFName = user.UserFName;
userToUpdate.UserLName = user.UserLName;
userToUpdate.UserName = user.UserName;
um.Update(userToUpdate);
}
}
}
return
Request.CreateResponse(HttpStatusCode.OK);
}
catch
(Exception ex)
{
Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
return
Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
}
}
Is there a way to save a copy of the PDF export to the server?
I have read that the proxyURL parameter will only be called if the browser doesn't support saving files locally. Is there no way to get the export functionality to post the generated file to the server?
I'm trying to get a copy of the exported pdf to attach to an email that will be sent out.
Any insight into this would be helpful.
Thanks!