- Home
- Forum
- ASP.NET Core
- Grid method addRecord does not work
Grid method addRecord does not work
5 Replies
VA
Venkatesh Ayothi Raman
Syncfusion Team
December 21, 2017 11:22 AM UTC
Hi Pratura,
Thanks for using Syncfusion products.
We went through your sample that you have shared for us and found that you are missed to define the edit settings property. Because, CRUD actions perform based on editSettings property. Please refer to the following Help documentation and code example,
|
<body>
.. .
<script type="text/javascript">
function myFunction() {
var gridObj = $("#Grid").data("ejGrid");
gridObj.addRecord({ "Name": "NewName", "City": "Newcity" });
};
$(function () {
$("#Grid").ejGrid({
dataSource: shipDetails,
editSettings: { allowAdding: true },
columns: [
. . .
]
});
});
</script>
</body> |
Help documentation: https://help.syncfusion.com/js/grid/editing
We have also modified your sample which can be referred from following link,
Note: Edit and delete operation can be performed based on Primary(unique) key column. It was explained in above Help documentation itself.
Also please refer to the following property whether to enable/disable the editing action while double click on the record,
Please let us know if you have any further assistance on this.
Regards,
Venkatesh Ayothiraman.
PR
Pratura
December 21, 2017 02:30 PM UTC
Thank you Venkatesh.
I am now trying to add every new record to the bottom of the grid with the option rowPosition:"bottom" but it keeps adding to the top
See the jsplayground please.
VA
Venkatesh Ayothi Raman
Syncfusion Team
December 22, 2017 05:56 AM UTC
Hi Pratura,
Thanks for using Syncfusion products.
We have achieved your requirement using the actionComplete event in Grid. Refer to the code example as below.
|
[Grid]
$("#Grid").ejGrid({
.. .
editSettings: { allowAdding: true, rowPosition:"bottom" },
. . .
actionComplete: "complete",
});
function complete(args) {
if (args.requestType == "save") {
this.model.dataSource.shift();// Remove the newly added record from first position
this.model.dataSource.push(args.data)// Push the newly added record in data source
this.refreshContent();
}
} |
We have also modified your sample which can be referred from following link,
Regards,
Venkatesh Ayothiraman.
PR
Pratura
December 22, 2017 07:12 AM UTC
Hi Venkatesh.
Thank you for the workaround.
Will this bug be corrected in the next version?
VA
Venkatesh Ayothi Raman
Syncfusion Team
December 26, 2017 09:32 AM UTC
Hi Pratura,
Thanks for the update.
Normally, in Grid added record shown at top of the Grid and rowPosition property is used for rendered the edit form in top or bottom like a form position property in Grid. In that, we can set the form position as BottomLeft or TopRight. This is the default behavior of the Grid.Please refer to the following Help documentation,
So, provided solution is not a workaround and this was an actual solution for your scenario. Please let us know if you have any further assistance on this.
Regards,
Venkatesh Ayothiraman.
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
-
PR Pratura
- Dec 20, 2017 10:51 AM UTC
- Dec 26, 2017 09:32 AM UTC