This is a migrated thread and some comments may be shown as answers.

External Form for Angular Grid

5 Answers 265 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
bhavin
Top achievements
Rank 1
bhavin asked on 10 Oct 2018, 01:52 PM

In the example 

https://www.telerik.com/kendo-angular-ui/components/grid/editing/external-editing/

as provided a call back is made to the service which fetches the Product data. Is there any easier way of achieving this? Also is there an example where the data is already defined in one of the ts over calling it from a link?

5 Answers, 1 is accepted

Sort by
0
bhavin
Top achievements
Rank 1
answered on 10 Oct 2018, 07:42 PM
Using the  would serve a better option than the  I feel
0
bhavin
Top achievements
Rank 1
answered on 11 Oct 2018, 07:59 PM

I am trying to call the data from within the application rather than the  but throwing me mine error. 

Is there any example that calls an internal  data rather than having it done via a link?

 

(Ref: https://www.telerik.com/kendo-angular-ui/components/grid/editing/external-editing/)

0
bhavin
Top achievements
Rank 1
answered on 11 Oct 2018, 08:01 PM

I have something like

  private _url: string = 'assets/notesData/';

private fetch(action: string = '', data?: any): Observable<any[]> {

    return this.http
      .jsonp(this._url+`/${action}?${this.serializeModels(data)}`, 'callback')
      .pipe(map(res => <any[]>res));
  }

All i get is "Uncaught ReferenceError: callback is not defined" all the time even if i tried various other routes

0
Accepted
Dimiter Topalov
Telerik team
answered on 12 Oct 2018, 12:34 PM
Hi Bhavin,

The External Form editing example utilizes a JSONP backend  that actually returns a callback function that is executed on the client and provides the data.

When trying to access some url (like "assets/notesData/") this should be an actual JSONP service so that it can function as expected with the syntax, used in the demo.

Further information about JSONP is available in multiple online resources, e.g.:

https://www.w3schools.com/js/js_json_jsonp.asp

Of course, you are not required to use JSONP or a remote server at all (using a remote data service is just the most common scenario). You can manipulate all data locally too.

In general, the Grid editing functionality relies on emitting events (edit, cancel, add, remove...). In the External Form editing example, the data item that should be edited (or a newly created one when adding a new item) is passed to the custom component, that contains the form and is responsible for binding the respective inputs to the proper data fields of the passed data item.

When the user is finished editing, the save event is emitted and handled in the host component (where in turn the respective edit service method is called).

For example to update the data only locally, you can customize the example by binding the Grid to an array of local data, and manipulate this array accordingly, e.g.:

https://stackblitz.com/edit/angular-4qf79s?file=app/app.component.ts

Note that the example is not fully functional - it just demonstrates a sample approach for editing local data without going through a service and remote server. Adding and removing new items is omitted for simplicity, but approach would be the same.

Further details about the Grid editing mechanics in general, are available in the following section of our documentation:

https://www.telerik.com/kendo-angular-ui/components/grid/editing/editing-reactive-forms/

I hope this helps.

Regards,
Dimiter Topalov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
bhavin
Top achievements
Rank 1
answered on 12 Oct 2018, 01:10 PM
Thanks for the demo, just a  the delete and add new is not working in the example provided
Tags
General Discussions
Asked by
bhavin
Top achievements
Rank 1
Answers by
bhavin
Top achievements
Rank 1
Dimiter Topalov
Telerik team
Share this question
or