This is a migrated thread and some comments may be shown as answers.

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

1 Answer 442 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 03 Nov 2015, 05:29 PM

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

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 04 Nov 2015, 09:10 AM

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
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or