jQuery UI Widgets › Forums › Lists › ComboBox › comboBox not return records
Tagged: Angular combobox, combobox, jquery combobox, jqxComboBox, json, JSONP
This topic contains 1 reply, has 2 voices, and was last updated by Dimitar 9 years ago.
-
Author
-
Hi could help me find what’s wrong with this code ?
The function in PHP is correct since it returned JSON , but comboBox does not show the records.code comboBox
`var source =
{
datatype: “jsonp”,
datafields: [
{ name: ‘id’ },
{ name: ‘identificador_relac’ },
{ name: ‘descricao’},
{ name: ‘quadro’ }
],
url: “http://localhost:8080/medidor/php/unitCombos.php?combo=jqxComboCanal”,
data: {
featureClass: “P”,
style: “full”,
maxRows: 12,
username: “jqwidgets”
}
};var dataAdapter = new $.jqx.dataAdapter(source,
{
formatData: function (data)
{
if ($(“#jqxComboCanal”).jqxComboBox(‘searchString’) != undefined)
{data.name_startsWith = $(“#jqxComboCanal”).jqxComboBox(‘searchString’);
return data;}
}
});$(“#jqxComboCanal”).jqxComboBox(
{
width: 250,
height: 25,
source: dataAdapter,
remoteAutoComplete: true,
autoDropDownHeight: true,
selectedIndex: 0,
displayMember: “descricao”,
valueMember: “identificador_relac”,
renderer: function (index, label, value) {
var item = dataAdapter.records[index];
if (item != null) {
var label = item.name + “(” + item.identificador_relac + “, ” + item.quadro + “)”;return label;
}
return “”;
},
renderSelectedItem: function(index, item)
{
var item = dataAdapter.records[index];
if (item != null) {
var label = item.descricao;
return label;
}
return “”;
},
search: function (searchString) {
dataAdapter.dataBind();
}
});code PHP
<?php
#Include the connect.php file
include (‘../conexao.php’);
date_default_timezone_set(‘America/Cuiaba’);
// Connect to the database
// gera comĀ“bo para pesquiza remota dos canais fisicosif ($_GET[“combo”]==’jqxComboCanal’)
{$descricao = $_GET[“name_startsWith”];
$query = ” SELECT “;
$query .= ” ID, “;
$query .= ” identificador_relac, “;
$query .= ” descricao, “;
$query .= ” quadro “;
$query .= ” From CF_CFG where upper(descricao) like ‘%’ || upper(:descricao) || ‘%’ “;
//echo $query.'<br>’;
$result = $conn->prepare($query);
//$result->bindParam(‘:calories’, $calories, PDO::PARAM_INT);
$result->bindParam(‘:descricao’, $descricao);
$result->execute();
$customers = ”;while ($linha = $result->fetch(PDO::FETCH_ASSOC))
{
$customers[] = array(
‘ID’ => $linha[‘ID’],
‘identificador_relac’ => $linha[‘identificador_relac’],
‘descricao’ => $linha[‘descricao’],
‘quadro’ => $linha[‘quadro’]
);
}
$total_rows = $result->rowCount();
//$result->fetch();
$data[] = array(
‘TotalRows’ => $total_rows,
‘Rows’ => $customers
);
echo json_encode($data);
/* close statement */
/* close connection */
}
?>`Hello americoneto1001,
If you are loading JSON data, please set the source object’s datatype to ‘json’. I also do not think you need to pass the extra parameters in data, because they are relevant only to the Binding to Remote Data demo.
var source = { datatype: "json", datafields: [{ name: 'id' }, { name: 'identificador_relac' }, { name: 'descricao' }, { name: 'quadro' }], url: "http://localhost:8080/medidor/php/unitCombos.php?combo=jqxComboCanal" };
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.