jQWidgets Forums
jQuery UI Widgets › Forums › Lists › ComboBox › Combobox inside grid makes multiple ajax calls
Tagged: jqxComboBox, jqxgrid
This topic contains 3 replies, has 2 voices, and was last updated by Peter Stoev 9 years, 1 month ago.
-
Author
-
Hi,
I have a jqxGrid with one of the columns as a jqxcombobox. The data for the combobox is loaded through an ajax call. The combo box makes the ajax call when its clicked on. For some reason, it makes 3 ajax calls. This really slows down my grid because my data set is quite huge. Here is a sample code of my grid.
$(document).ready(function () { url = 'combobox.php'; source = { datatype: "json", datafields: [ { name: 'name' } ], type: "POST", id: 'id_field', url: url, async: false, }; ListAdapter = new $.jqx.dataAdapter(source, { autoBind: true, async: false, width: 120 }); // bind to 'select' event. // prepare the data var gridSource = { datatype: "json", localdata: [ {"username":"XYZ"} ], datafields: [ { name: 'username":"', type: 'string'} ], id: 'id_field', root: 'root', cache: false, async: false, }; var gridAdapter = new $.jqx.dataAdapter(gridSource); $("#jqxgrid").jqxGrid( { width: 600, source: gridAdapter, selectionmode: 'singlecell', autoheight: true, editable: true, columns: [ { text: 'Country',datafield: 'username":"', columntype: 'combobox', createeditor: function (row, cellvalue, editor) { editor.jqxComboBox({selectedIndex: -1, source: ListAdapter, autoComplete: true, displayMember: "name", valueMember: "name", promptText: "Please Choose:", }); editor.on('change', function (event) { //$("#jqxgrid").jqxGrid('addrow', null, {}, 'last'); }) }, }, ] }); });
combobox.php
<?php $firstNames = array("Andrew", "Nancy", "Shelley", "Regina", "Yoshi", "Antoni", "Mayumi", "Ian","Peter", "Lars", "Petra", "Martin", "Sven", "Elio", "Beate", "Cheryl", "Michael", "Guylene"); $i=0; foreach($firstNames as $code){ $codes[$i]['name'] = trim($code); $i++; } echo json_encode($codes); ?>
Please guide me on how to restrict to a single ajax call.
Regards,
RichaHi Richa,
The problem is that you set autoBind: true.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
Thank you for the reply.
I removed the autoBind: true property but its still making multiple calls. Can you please share a working example of jqcombobox inside jqgrid which doesn’t make these multiple ajax calls.Thanks
Regards,
RichaRicha, which version do you use? jqxComboBox does not have promptText property. If your data set is large, you might consider using remoteAutoComplete feature of jqxComboBox, too.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.