Not sending dataTextField when editing

0 Answers 116 Views
ComboBox
Fatemeh
Top achievements
Rank 1
Iron
Fatemeh asked on 09 Jul 2022, 10:51 AM

I have written the following code for kendoComboBox, it does not cause any problem when creating, but when editing, only the id is displayed.

 

 


   $('#buyer').kendoComboBox({
                        dataSource: new kendo.data.DataSource({
                            type: 'aspnetmvc-ajax',
                            serverFiltering: true,
                            serverPaging: true,
                            serverSorting: true,
                            transport: {
                                read: {
                                    url: kmc.urlBase + '/lookups/buyers',
                                    dataType: 'json',
                                    type: 'POST',
                                    beforeSend: function (xhr) {
                                        kmc.setRequestVerificationToken(xhr);
                                    }
                                }
                            },
                            schema: {
                                aggregateResults: 'aggregateResults',
                                data: 'data',
                                errors: 'errors',
                                total: 'total',
                                model: {
                                    id: 'id',
                                    fields: {
                                        id: { type: 'number' },
                                        name: { type: 'string' },
                                        code: { type: 'string' },
                                        cidNID: { type: 'string' },
                                        addr: { type: 'string' },
                                        tel: { type: 'string' },
                                        fax: { type: 'string' }
                                    }
                                }
                            },
                            error: function (e) {
                                if (e.status === 'customerror') {
                                    pki.alert(e.errors);
                                } else {
                                    var failure = pki.parseJson(e.xhr.responseText);
                                    if (failure && failure.success === false) {
                                        pki.alert('Status: ' + e.xhr.status + '<br/><br/>Error: ' + failure.errors);
                                    } else {
                                        pki.alert('Status: ' + e.xhr.status + '<br/><br/>Error: ' + e.xhr.responseText);
                                    }
                                }
                            }
                        }),
                        dataTextField: 'name',
                        dataValueField: 'id',
                        filter: 'startswith',
                        valuePrimitive: true,
                        //change: function (e) {
                        //    var dataItem = this.dataItem();
                        //    if (dataItem) {
                        //        pro.headerModel.set('buyer', { id: dataItem.Id, name: dataItem.Name });
                        //    }
                        //},
                        minLength: 2,
                        select: function (e) {
                            var item = e.dataItem;
                            if (item) {
                                $('#buyer-name').text(`TO: ${item.name}`);
                                $('#buyer-addr').text(`ADD: ${item.addr}`);
                                $('#buyer-tel').text(`TEL: ${item.tel}`);
                                $('#buyer-fax').text(`FAX: ${item.fax}`);
                                $('#buyer-nid').text(`COMMERCIAL/NATIONAL ID: ${item.cidNID}`);
                            }
                        }
                    });







 






 html code :

                                <td>
                                <span class="caption">Buyer: </span>
                                <input id="buyer" name="buyer" class="combobox-lg" data-bind="value: buyer.id" required />
                               </td>

Lyuboslav
Telerik team
commented on 11 Jul 2022, 10:36 AM

Hi Fatemeh,

Could you please send me some more information about the exact scenario and implementation? You mention creating and editing, but I didn`t notice the create/update endpoints configured in your dataSource. Is your ComboBox initialized in the Grid?

You can take a look at our demo, it could be useful for your scenario because  adding item to the ComboBox is presented. I would appreciate it If you could prepare a dojo example demonstrating your scenario and share it with me. This way I could understand the issue better and advise you further. 

Regards,
Lyubo
Progress Telerik

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Fatemeh
Top achievements
Rank 1
Iron
Share this question
or