hi,
i did a function using jqxtree(JSON) and its working fine.
i need to know how to display a message, when there is no data to display in jqxtree.
example message: no data to display.
here is my code
<script type="text/javascript">
$(document).ready(function () {
var theme = 'ui-redmond';
$('#submit').click(function() {
//validate fields
if(document.getElementById('txt_input').value == '')
{
alert("Please enter a value");
}
else
{
disp_tree();
}
});
// prepare the data
var disp_tree = function() {
$('#jqxWidget').html('<img src="js/jqwidgets/resources/loader_2.gif"><img>');
var search = document.getElementById('txt_input').value;
var cate = document.getElementById('ddl_list').value;
var source =
{
datatype: 'json',
datafields: [
{ name: 'id' },
{ name: 'parentid' },
{ name: 'text' },
{ name: 'value' }
],
//theme: theme,
url: 'tree_view.php?search='+search+"&cate="+cate,
id: 'id',
root: 'data',
async: false
};
// create data adapter.
var dataAdapter = new $.jqx.dataAdapter(source);
// perform Data Binding.
dataAdapter.dataBind();
// get the tree items. The first parameter is the item's id. The second parameter is the parent item's id. The 'items' parameter represents
// the sub items collection name. Each jqxTree item has a 'label' property, but in the JSON data, we have a 'text' field. The last parameter
// specifies the mapping between the 'text' and 'label' fields.
var records = dataAdapter.getRecordsHierarchy('id', 'parentid', 'items', [{ name: 'text', map: 'label'}]);
$('#jqxWidget').jqxTree({ source: records, width: '300px'});
};
});
</script>
thank you.