{"action":"created","issue":{"url":"https://api.github.com/repos/tabalinas/jsgrid/issues/767","repository_url":"https://api.github.com/repos/tabalinas/jsgrid","labels_url":"https://api.github.com/repos/tabalinas/jsgrid/issues/767/labels{/name}","comments_url":"https://api.github.com/repos/tabalinas/jsgrid/issues/767/comments","events_url":"https://api.github.com/repos/tabalinas/jsgrid/issues/767/events","html_url":"https://github.com/tabalinas/jsgrid/issues/767","id":227036318,"number":767,"title":"Help request: How do I remove a row from the grid","user":{"login":"Junglefish","id":23358803,"avatar_url":"https://avatars3.githubusercontent.com/u/23358803?v=3","gravatar_id":"","url":"https://api.github.com/users/Junglefish","html_url":"https://github.com/Junglefish","followers_url":"https://api.github.com/users/Junglefish/followers","following_url":"https://api.github.com/users/Junglefish/following{/other_user}","gists_url":"https://api.github.com/users/Junglefish/gists{/gist_id}","starred_url":"https://api.github.com/users/Junglefish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Junglefish/subscriptions","organizations_url":"https://api.github.com/users/Junglefish/orgs","repos_url":"https://api.github.com/users/Junglefish/repos","events_url":"https://api.github.com/users/Junglefish/events{/privacy}","received_events_url":"https://api.github.com/users/Junglefish/received_events","type":"User","site_admin":false},"labels":[{"id":141287457,"url":"https://api.github.com/repos/tabalinas/jsgrid/labels/help%20wanted","name":"help wanted","color":"159818","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-05-08T12:53:29Z","updated_at":"2017-06-19T01:33:21Z","closed_at":"2017-05-19T22:04:37Z","body":"Hi\r\n\r\nI have seen the other similar answers to this often-asked question, but I'm still having a difficulty.\r\n\r\nI have a very simple grid:\r\n\r\n```html\r\n\t\t<script>\r\n\t\t\t$(function() {\r\n\t\t\t \r\n\t\t\t    $(\"##jsGrid\").jsGrid({\r\n\t\t\t        height: \"auto\",\r\n\t\t\t        width: \"100%\",\r\n\t\t\t        autoload: true,\r\n\t\t\t        sorting: true,\r\n\t\t\t        paging: true,\r\n\t\t\t        pageSize: 10,\r\n\t\t\t        pageButtonCount: 5,\r\n\t\t\t        editing: false,\r\n\r\n\t\t\t        controller: {\r\n\t\t\t            loadData: function() {\r\n\t\t\t                var d = $.Deferred();\r\n\t\t\t \r\n\t\t\t                $.ajax({\r\n\t\t\t                    url: \"#event.buildLink(\"Transactions.transactionsAsJson\")#\",\r\n\t\t\t                    dataType: \"json\"\r\n\t\t\t                }).done(function(response) {\r\n\t\t\t                    //d.resolve(response.value);\r\n\t\t\t                    d.resolve(response);\r\n\t\t\t                });\r\n\t\t\t\r\n\t\t\t                return d.promise();\r\n\t\t\t            }\r\n\t\t\t        },\r\n\t\t\t\r\n\t\t\t        fields: [\r\n\t\t\t            { name: \"TRLO_KY\", title: \"Trans key\", type: \"number\"},\r\n\t\t\t\t\t\t{ \r\n\t\t\t\t\t\t\t  name: \"TRLO_TRANSACTION_DATETIME\"\r\n\t\t\t\t\t\t  \t, title: \"Date\"\r\n\t\t\t\t\t\t  \t, type: \"text\"\r\n\t\t\t\t\t\t  \t, align: \"right\"\r\n\t\t\t\t\t\t  \t, itemTemplate: function(value, item) { \r\n\t\t\t\t\t\t    \tdtDate = new Date(item.TRLO_TRANSACTION_DATETIME);\r\n\t\t\t\t\t\t    \treturn $.format.date(dtDate, \"dd MMMM yyyy\");\r\n\t\t\t\t\t\t  \t}\r\n\t\t\t\t\t\t \t, sorter: function(d1, d2) {\r\n\t\t\t\t\t\t    \tvar date1 = new Date(d1).getTime();\r\n\t\t\t\t\t\t    \tvar date2 = new Date(d2).getTime();\r\n\t\t\t\t\t\t    \treturn (date1>date2)-(date1<date2);\r\n\t\t\t\t\t\t  \t}\r\n\t\t\t\t\t\t  \t, headercss: \"align-right\"\r\n\t\t\t\t\t\t},\r\n\t\t\t            { name: \"USER_FULLNAME\", title: \"By\", type: \"text\"},\r\n\t\t\t            { name: \"TRLO_RECORD_TABLE\", title: \"Record type\", type: \"text\"},\r\n\t\t\t            { name: \"TRLO_RECORD_KY\", title: \"Record key\", type: \"number\"},\r\n\t\t\t            { name: \"RECORD_TITLE\", title: \"Record title\", type: \"text\"},\r\n\t\t\t            { name: \"TRLO_RECORD_COLUMN\", title: \"Field\", type: \"text\"},\r\n\t\t\t            { name: \"TRLO_RECORD_ACTION\", title: \"Action\", type: \"text\"},\r\n\t\t\t            { name: \"TRLO_STARTVALUE\", title: \"Was\", type: \"text\"},\r\n\t\t\t            { name: \"TRLO_ENDVALUE\", title: \"Is now\", type: \"text\"},\r\n\t\t\t            { \t\r\n\t\t\t            \theaderTemplate: function() {\r\n\t\t\t                    //return $(\"<button>\").attr(\"type\", \"button\").text(\"Add\").on(\"click\", function () {\r\n\t\t\t                    //\twindow.location = '#event.buildLink(linkTo=\"Committees.addCommittee\")#';\r\n\t\t\t                    //});\r\n\t\t\t                }\t\r\n\t\t\t            \t, itemTemplate: function(value, item) {\r\n\t\t\t                    return '<input type=\"button\" value=\"Approve\" name=\"approve\" onClick=\"javascript:approveTransaction(' + item.TRLO_KY + ', \\'#event.buildLink(linkTo=\"Transactions.approveTransactionAjax\")#\\');\" />';\r\n\t\t\t                }    \r\n\t\t\t            }\r\n\t\t\t         ]\r\n\t\t\t    });\r\n\t\t\t});\r\n\t\t</script>\r\n```\r\n\r\nThe action button fires a self-baked JS function approveTransaction() that fires an ajax call back to the server:\r\n\r\n```js\r\n\tfunction approveTransaction(nTrloKy, szEvent) {\r\n\t\t//console.log(item);\r\n\t\t//return false;\r\n\t\tif (confirm(\"Are you sure you want to approve this transaction?\")) {\r\n\t\t\t$.ajax({\r\n\t\t\t\tmethod: \"POST\",\r\n\t\t\t\turl: szEvent,\r\n\t\t\t\tdata: { trlo_ky: nTrloKy }\r\n\t\t\t})\r\n\t\t\t.done(function( msg ) {\r\n\t\t\t\tif (msg.search(\"true\") == 0) {\r\n\t\t\t\t\talert(\"The transaction has been approved\");\r\n\t\t\t\t\t\r\n\t\t\t\t\t// REMOVE THE ROW FROM THE GRID!!! HOW???\r\n\t\t\t\t\t$(\"#jsGrid\").jsGrid(\"deleteItem\", data[0]); // delete first item\r\n\t\t\t\t\t\r\n\t\t\t\t} else {\r\n\t\t\t\t\talert(\"The operation failed\")\r\n\t\t\t\t\t// Developer was alerted in Transactions.approveTransactionAjax()!\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n```\r\n\r\nHowever, when I try to remove the row from the grid, 'data[n]' is not defined.\r\n\r\nCan anyone see what's missing?\r\n"},"comment":{"url":"https://api.github.com/repos/tabalinas/jsgrid/issues/comments/309318309","html_url":"https://github.com/tabalinas/jsgrid/issues/767#issuecomment-309318309","issue_url":"https://api.github.com/repos/tabalinas/jsgrid/issues/767","id":309318309,"user":{"login":"tabalinas","id":3506013,"avatar_url":"https://avatars3.githubusercontent.com/u/3506013?v=3","gravatar_id":"","url":"https://api.github.com/users/tabalinas","html_url":"https://github.com/tabalinas","followers_url":"https://api.github.com/users/tabalinas/followers","following_url":"https://api.github.com/users/tabalinas/following{/other_user}","gists_url":"https://api.github.com/users/tabalinas/gists{/gist_id}","starred_url":"https://api.github.com/users/tabalinas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tabalinas/subscriptions","organizations_url":"https://api.github.com/users/tabalinas/orgs","repos_url":"https://api.github.com/users/tabalinas/repos","events_url":"https://api.github.com/users/tabalinas/events{/privacy}","received_events_url":"https://api.github.com/users/tabalinas/received_events","type":"User","site_admin":false},"created_at":"2017-06-19T01:33:21Z","updated_at":"2017-06-19T01:33:21Z","body":"@Junglefish, you are welcome!"}}
{"actor":{"display_login":"tabalinas"}}