We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

EJGRID | Add Button Programmatically

Hello,

I wonder what are the methods used in the grid because i need to make a customized buttons like add, remove and edit the line

As image: 



Thank you

David Almas

3 Replies

DA David Almas July 20, 2015 07:16 PM UTC

Resolved with addRecord() Method.

Thank you


DA David Almas July 20, 2015 09:52 PM UTC

Hi again,

What can i do to save row when i do a addRecord() method ?

Thanks


GV Gowthami V Syncfusion Team July 21, 2015 11:20 AM UTC

Hi David,

Thanks for using Syncfusion products.

Query 1: what are the methods used in the grid because i need to make a customized buttons like add, remove and edit the line

Please refer the below link for performing add, remove and edit the record externally.

For adding the row: https://help.syncfusion.com/api/js/ejgrid#methods:addrecord

For delete the record: https://help.syncfusion.com/api/js/ejgrid#methods:deleterecord

For Edit the record: https://help.syncfusion.com/api/js/ejgrid#methods:startedit

For saving the record: https://help.syncfusion.com/api/js/ejgrid#methods:endedit

Query 2: What can i do to save row when i do a addRecord() method ?

We can add the record in two ways externally by using addRecord method.

1.       We can add the empty record and then add the corresponding fields then we can save the added/edited record using “endEdit” method of the grid as follows.

//Getting instance of the grid

var gridObj = $("#Grid").data("ejGrid");

//Add the below code to the click event of the external button “Adicionar” for add the record

gridObj.addRecord();

               

//Add the below code to the click event of the external button “Guardar” for sending save request

gridObj.endEdit();


2.       We can add the record by passing the record to the addRecord method itself as follows.


var gridObj = $("#Grid").data("ejGrid");


//Use the below code for add and save the record automatically without calling the method “endEdit” .

gridObj.addRecord({OrderID:12333});


While using above code snippet, there is no need to send the save request using “endEdit” method. The added record will automatically get saved.

Please let us know if you have any queries.

Regards,
Gowthami V.

Loader.
Up arrow icon