institut-de-genomique / Ultimate-DataTable

This AngularJS directive generate a HTML table with build-in fonctionnality like save, edit, remove, pagination etc...
http://institut-de-genomique.github.io/Ultimate-DataTable/
45 stars 26 forks source link

Lack example for validation in editable fields #41

Open bfallar3 opened 6 years ago

bfallar3 commented 6 years ago

Can you provide a sample on how to display and response an error to the dataTable when it fails validation?

galbini commented 6 years ago

You need to return an object where fields is the same as column.property value.

Example with the folowing two columns column : { property:"name" }

column:{ property:"trace.creationDate" }

the return of server must be of this form

{ "name":["bad format : only [A-Za-z]"], "trace.creationDate":["required"] }

I hope that help you.

bfallar3 commented 6 years ago

What specific server-side function (e.g. controller/API) that the server should throw this data

{ "name":["bad format : only [A-Za-z]"], "trace.creationDate":["required"] } This is what indicated in the documentation but its too vague. In the “url” of the Save property, it throws an Http Bad Request, but I need to construct the specific data to send back from the server.

From: Guillaume Albini [mailto:notifications@github.com] Sent: Wednesday, October 11, 2017 10:11 PM To: institut-de-genomique/Ultimate-DataTable Ultimate-DataTable@noreply.github.com Cc: bfallar3 bfallar3@hotmail.com; Author author@noreply.github.com Subject: Re: [institut-de-genomique/Ultimate-DataTable] Lack example for validation in editable fields (#41)

You need to return an object where fields is the same as column.property value.

Example with the folowing two columns column : { property:"name" }

column:{ property:"trace.creationDate" }

the return of server must be of this form

{ "name":["bad format : only [A-Za-z]"], "trace.creationDate":["required"] }

I hope that help you.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/institut-de-genomique/Ultimate-DataTable/issues/41#issuecomment-335823349, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADEvRpsfNsGfehGEkpoyFha6KItICKo1ks5srMxagaJpZM4P0WsT.

bfallar3 commented 6 years ago

Here is the code snippet for my AngularJs script that performs ‘remote’ save

[cid:image001.png@01D342E1.2984F310]

Here is my server-side code

[cid:image002.png@01D342E1.2984F310]

Cheers, Benjie

From: Guillaume Albini [mailto:notifications@github.com] Sent: Wednesday, October 11, 2017 10:11 PM To: institut-de-genomique/Ultimate-DataTable Ultimate-DataTable@noreply.github.com Cc: bfallar3 bfallar3@hotmail.com; Author author@noreply.github.com Subject: Re: [institut-de-genomique/Ultimate-DataTable] Lack example for validation in editable fields (#41)

You need to return an object where fields is the same as column.property value.

Example with the folowing two columns column : { property:"name" }

column:{ property:"trace.creationDate" }

the return of server must be of this form

{ "name":["bad format : only [A-Za-z]"], "trace.creationDate":["required"] }

I hope that help you.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/institut-de-genomique/Ultimate-DataTable/issues/41#issuecomment-335823349, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADEvRpsfNsGfehGEkpoyFha6KItICKo1ks5srMxagaJpZM4P0WsT.

galbini commented 6 years ago

I don't see your code snippet. no images attach.

The save must be execute by UDT. UDT used the save.url configuration to call your server.

Then your server api need to return a HttpResponse with code different than 200 with a JSON object in the body response. The json object must be match the rules describe in the first comment.

Guillaume

bfallar3 commented 6 years ago

Great thanks!

Get Outlook for Androidhttps://aka.ms/ghei36


From: Guillaume Albini notifications@github.com Sent: Wednesday, October 11, 2017 11:20:39 PM To: institut-de-genomique/Ultimate-DataTable Cc: bfallar3; Author Subject: Re: [institut-de-genomique/Ultimate-DataTable] Lack example for validation in editable fields (#41)

I don't see your code snippet. no images attach.

Your server api need to return a HttpResponse with code different than 200 with a JSON object in the body response. The json object must be match the rules describe in the first comment.

Guillaume

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/institut-de-genomique/Ultimate-DataTable/issues/41#issuecomment-335846995, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADEvRqgqofRUCc2MFMke2WU-7maD1Ol7ks5srNzHgaJpZM4P0WsT.