question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

insertItem problem

See original GitHub issue

Hello,

I have a problem with the insertItem function. Here is my code:

        var teams= [
            { "Name": "ATLAS" },
            { "Name": "ALICE" },
        ]; 
        var grid = $("#jsGrid").jsGrid({
            //...SOME PARAMS HERE...
            data: teams,
     
            fields: [
                { name: "Name", type: "text", width: 150, validate: "required" },
                { type: "control" }
            ],

            insertItem: function (item) {
                var d = $.Deferred();
                
                $.ajax({
                  method: "POST",
                  url: "/admin/team/insert/",
                  data: item,
                  dataType: "json",
                }).done(function( data ) {
                    console.log( "done:" + JSON.stringify(data) );
                    d.resolve(data);
                }).fail(function( msg ) {
                    console.log( "fail" + msg );
                    d.reject();
                });
                
                return d.promise();
            }
        });

The data returned from my server is {"Name":"foo"}. But the new row is never inserted. My jquery is jquery-3.1.1.min.js. I have tried with jquery-1.11.3.min.js without success. I have tried to hard code d.resolve({ "Name": "foo" }).

I may have misunderstood how the function work. Where is my mistake ? Thanks. Regards, Thomas

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tabalinascommented, Dec 15, 2016

You need to define insertItem method in the controller option http://js-grid.com/docs/#controller.

0reactions
tabalinascommented, May 29, 2017

@kjindal, in case of resolve the insertion will be completed and item will be added to the grid. In case of reject insertion will be canceled.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with wxListCtrl::InsertItem() - Google Groups
Hello, I'm trying to insert a string into my wxListCtrl like so: wxListItem newItem; newItem.SetId( count ); newItem.SetColumn( 0 ); newItem.
Read more >
Problem in CTreeCtrl::InsertItem - MSDN - Microsoft
Hi everybody, I have a problem in MFC(VC++) and developing SDI application.When i call InsertItem function in onInitDialog of the dialog box
Read more >
wxListCtrl: InsertItem Problem - wxWidgets Discussion Forum
Hello, i am a little bit confused. long wxListCtrl::InsertItem(long index, const wxString& label) This method returns a long var and needs a ...
Read more >
ListView InsertItem problem (URGENT)
User-1176222693 posted. Hi, I have created a Master-Details Pages (GridView is parent and ListView is child). When i click the select button in...
Read more >
Products Insert Problem - apex - Salesforce Stack Exchange
Below is my webservice i would like to insert products before quotes insert may i know how can i do this. while i...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found