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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Set the keyField for CRUD Operations

Thread ID:

Created:

Updated:

Platform:

Replies:

143665 Mar 30,2019 06:07 PM UTC Apr 1,2019 02:21 PM UTC Vue 2
loading
Tags: Data Grid
Chris
Asked On March 30, 2019 06:07 PM UTC

I use the WebApiAdaptor for remote data source. I also want to use the CommandColumn Option to delete the entries.
The issue now is, that the keyField is undefined in the remove function. So I receive urls like `http://example.com/user/undefined` . How do I set the correct key? In my case the key has the name hash and is not displayed in the grid, but is available in the source. I tried to define the key element in the Datamanager section, but I guess it's the wrong part.
<ejs-grid ref='grid' :data-source="gridSource" :allow-paging="true"
>
<e-columns>
<e-column type='checkbox' width='50'>e-column>
<e-column field='firstname' header-text='Filename' width=90 :template="userTemplate">e-column>
<e-column field='account_created' header-text='Created at' width=90>e-column>
<e-column headerText='Manage Records' width='160' :commands='commands'>e-column>
e-columns>
ejs-grid>


data() {
return {

gridSource: new DataManager({
url: '/user',
adaptor: new WebApiAdaptor({

}),
key: 'hash'
}),
commands: [
{ type: 'Delete', buttonOption: { iconCss: 'e-icons e-delete', cssClass: 'e-flat' } },
],
}}

Thanks in advance

Thavasianand Sankaranarayanan [Syncfusion]
Replied On April 1, 2019 07:23 AM UTC

Hi Christopher, 

Greetings from Syncfusion support. 

We have checked your query and we suspect that you did not provide primaryKey to the Grid. PrimaryKey is important when you perform deletion in Grid. So, please enable the primaryKey column by set isPrimaryKey property as true.  

Note: PrimaryKey column must be have the unique values.  

Refer the help documentation. 
 
 
  
If it’s not satisfy your requirement, Could please provide below details that will be helpful for us to provide better solution as early as possible. 

  1. Please share your Grid code.
  2. Share the screenshot of developer tool console to check script error if any.

Regards, 
Thavasianand S. 


Chris
Replied On April 1, 2019 02:21 PM UTC

Hello Thavasianand,

thanks for the hint. solved my issue.

Another question. Is it possible to hook in to the deletion process and show a toast with a message from the server if the deletion process was successfull or not?

Regards

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;