Trying to call Create action on Grid using JQuery (MVC)

2 posts, 0 answers
  1. Corey
    Corey avatar
    13 posts
    Member since:
    Sep 2015

    Posted 03 Nov 2015 Link to this post

    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

  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 04 Nov 2015 Link to this post

    Hello Corey,

    You could use the .Data() method to specify a JavaScript function that will pass additional data to the create action and retrieve the input value in this function.
    E.g.

    .Create(update => update.Action("Create", "Grid").Data("additionalData"))

    function additionalData() {
        return {
            firstName: "John",
            lastName: "Doe"
        };
    }

    Regards,
    Dimiter Madjarov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top