Telerik Forums
UI for ASP.NET MVC Forum
1 answer
564 views

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

Dimiter Madjarov
Telerik team
 answered on 04 Nov 2015
11 answers
197 views

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

Jonas
Top achievements
Rank 1
 answered on 04 Nov 2015
1 answer
144 views

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

Kiril Nikolov
Telerik team
 answered on 04 Nov 2015
1 answer
113 views

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 ​

Alexander Popov
Telerik team
 answered on 04 Nov 2015
3 answers
408 views
I have a grid in which I would like to use batch editing.  However, the update is not working - I am seeing no data when I hit the Web API controller.  I have read the Web API editing document on the Kendo site and I have looked at the example application in the download of UI for ASP.NET MVC.  I have Googled and searched these forums. I can find no example of batch editing using Web API without OData.  I am not using OData.  If anyone can be of assistance, I would be so very appreciative!  I can get inline editing to work, no problem.  But I would really like to use batch editing.
I have attached a couple of screen shots showing the empty parameter on my controller method and the request header and data from the Web API call.

Here is my code:

Grid:
@(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))
    )
)

WebAPI Controller code for update:
/// <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);
    }
}

Thanks!
Donna

Robert
Top achievements
Rank 1
 answered on 03 Nov 2015
1 answer
98 views

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!

Kiril Nikolov
Telerik team
 answered on 03 Nov 2015
1 answer
161 views

We are experiencing an issue with our MVC SiteFinity application. When editing a grid inline having a foreign key dropdown column set as the first column displayed in the grid its necessary to click the grid confirm button twice to display all validation messages when the row ​has no data entered. The first click displays the validation message for the foreign key dropdown column and the second click then displays all subsequent column validation messages. The css code listed below is used to prevent another issue that was causing the validation message tool-tip for the dropdown foreign key column to be displayed underneath the subsequent row of the grid. If the foreign key dropdown column is not set as the first column in the grid on click of the confirm button then the validation messages all get displayed correctly when no data is entered.

// Gridview
<div class="row" id="divGridApplicationStatuts" style="padding-top: 0px;">
      @(Html.Kendo().Grid<SitefinityWebApp.Mvc.Models.TypeActiviteReglementModel>()
           .Name("GridTypeActiviteReglements")
           .Columns(columns =>
           {
              columns.Bound(p => p.Id).Title("No.").Width(25).Filterable(false).Sortable(true);
              columns.ForeignKey(p => p.BeneficierId, (System.Collections.IEnumerable)ViewBag.Beneficiers, dataFieldValue: "BeneficierId", dataFieldText: "BeneficierName").Title("Bénéficier").Width(85).Filterable(true).Sortable(true).EditorTemplateName("TypesActivitesReglementsBeneficierEditor");
              columns.Bound(p => p.Nom).Title("Type d'activité").Width(300).Filterable(false).Sortable(true);
              columns.Command(command =>
              {
                  command.Edit().Text("Éditer").UpdateText("Confirmer").CancelText("Annuler").HtmlAttributes(new { style = "padding:3px" });
                          command.Destroy().Text("Supprimer").HtmlAttributes(new { style = "padding:3px" });
              }).Width(90);
              })
             .ToolBar(toolbar => toolbar.Create().Text("Ajouter"))
             .Scrollable(scr => scr.Height(570))
             .Sortable()
             .Pageable()
             .Filterable()
             .Editable(editable => editable.Mode(GridEditMode.InLine))
             .HtmlAttributes(new { style = "width:1048px" })
             .Events(ev => ev.Edit("onEdit").Save("onSave"))
             .DataSource(dataSource => dataSource
                     .Ajax()
                     .AutoSync(false)
                     .Events(e => e.RequestEnd("onRequestEnd"))
               .Model(model =>
               {
                   model.Id(p => p.Id);
               })
               .Sort(s => s.Add("Id").Ascending())
               .PageSize(12)
               .Events(events => events.Error("error"))
               .Read(read => read.Url("/tar/TypesActivitesReglements/TypesActivitesReglementsRead").Data("sendAntiForgeryToken"))
               .Create(create => create.Url("/tar/TypesActivitesReglements/TypesActivitesReglementsCreate").Data("sendAntiForgeryToken"))
               .Update(update => update.Url("/tar/TypesActivitesReglements/TypesActivitesReglementsUpdate").Data("sendAntiForgeryToken"))
               .Destroy(destroy => destroy.Url("/tar/TypesActivitesReglements/TypesActivitesReglementsDestroy").Data("sendAntiForgeryToken"))
               .ServerOperation(true)
               )
               )
</div>
 
// Dropdown foreign key template
 
@(Html.Kendo().DropDownListFor(model => model)       
    .OptionLabel("- Sélectionnez - ")
    .Name("BeneficierList")
    .DataValueField("BeneficierId")
    .DataTextField("BeneficierName")
    .BindTo((IEnumerable)ViewBag.Beneficiers)
      )
 
// Style fix
<style>
    .k-tooltip {
        /*height: 25px;*/
        position: static;
        white-space: normal;
    }
 
    .k-tooltip-validation .k-invalid-msg {
        display: block;
    }
 
    .k-invalid-msg .k-callout {
        display: block;
    }
</style>

Vladimir Iliev
Telerik team
 answered on 03 Nov 2015
1 answer
107 views

Hi,

Q.1) I am using the detailed template for the MVC grid. I am trying to lock the column of main grid but it showing the error detailed template can not have locked column.

Please let me know if there is any work around to do that.

Q.2) I want to show/hide the detailed template for the grid on the selection and deselection of the check box. Any idea how do I achieve this at run time.

Nikolay Rusev
Telerik team
 answered on 03 Nov 2015
1 answer
90 views
Is there a way to turn on multiple EditModes in order to paste Excel data into the grid?
Kiril Nikolov
Telerik team
 answered on 03 Nov 2015
17 answers
599 views

Hi

I want to display 3 level grid in Kendo, i.e. after clicking arrow on 1st grid row, it opens 2nd grid, and after clicking arrow on 2nd grid row, it opens 3rd grid. I use ClientDetailTemplateId to do it. Here is the code:

1st Kendo Grid

        <% Html.Kendo().Grid<MaintenanceSportsGridSportViewModel>()
            .Name("Sports")
           .DataSource(dataSource => dataSource
                    .Ajax()
                    .Model(model => model.Id(a => a.SportId))
                    .ServerOperation(true)
                    .Read(read => read.Action("MaintenanceSportsAjax", "Maintenance"))
                    .Update(update => update.Action("UpdateMaintenanceSports", "Maintenance").Data("onUpdateMaintenanceSports"))
                    .Events(a => a.RequestEnd("onMaintenanceSportsGridRequestEnd"))
                )
...
            .ClientDetailTemplateId("DisciplinesTemplate")
            .Columns(columns =>
            {
                columns.Bound(s => s.SportCode).Width(70);
...
            }).Render();
            
        %>

2nd Grid

        <%: Html.Kendo().Grid<MaintenanceSportsGridDisciplineViewModel>()
            .Name("Disciplines_#=SportId#")
            .DataSource(dataSource => dataSource
                    .Ajax()
                    .Model(model => model.Id(a => a.DisciplineId))
                    .ServerOperation(false)
                    .Events(e => e.RequestEnd("onMaintenanceDisciplinesRequestEnd"))
                    .Create(create => create.Action("InsertMaintenanceDisciplines", "Maintenance", new { parentSportId = "#=SportId#" }))
                    .Read(read => read.Action("MaintenanceDisciplinesAjax", "Maintenance", new { sportId = "#=SportId#" }))
                    .Update(update => update.Action("UpdateMaintenanceDisciplines", "Maintenance").Data("onUpdateMaintenanceDisciplines"))
                    .Destroy(destroy => destroy.Action("DeleteMaintenanceDisciplines", "Maintenance").Data("onUpdateMaintenanceDisciplines"))
                )
...
            .ClientDetailTemplateId("EventsTemplate")
            .Columns(columns =>
            {
                columns.Bound(b => b.SportCode)
                    .Width(70);
...
            })

           .ToClientTemplate()         
      %>     
3rd grid

        <%: Html.Kendo().Grid<MaintenanceSportsGridEventViewModel>()
            .Name("Events_#=DisciplineId#")
            .DataSource(dataSource => dataSource
                    .Ajax()
                    .Model(model => model.Id(a => a.EventId))
                    .ServerOperation(false)
                    .Events(e => e.RequestEnd("onMaintenanceEventsRequestEnd"))
                    .Create(create => create.Action("InsertMaintenanceEvents", "Maintenance", new { parentDisciplineId = "#=DisciplineId#" }))
                    .Read(read => read.Action("MaintenanceEventsAjax", "Maintenance", new { disciplineId = "#=DisciplineId#" }))
                    .Update(update => update.Action("UpdateMaintenanceEvents", "Maintenance").Data("onUpdateMaintenanceEvents"))
                    .Destroy(destroy => destroy.Action("DeleteMaintenanceEvents", "Maintenance").Data("onUpdateMaintenanceEvents"))
                )
...
            .Columns(columns =>
            {
                columns.Bound(b => b.SportCode)
                    .Width(60);
...
            })
            .ToClientTemplate()         
      %>     
But the problem is that I can not open the 3rd grid. 2nd grid works fine. I need help on this.

​​

york
Top achievements
Rank 1
 answered on 03 Nov 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?