EasyUI Forum

General Category => General Discussion => Topic started by: anugrast on July 24, 2018, 01:17:59 AM



Title: SearchBox Category Load From Table/Database
Post by: anugrast on July 24, 2018, 01:17:59 AM
Hai.... can we load SearchBox Category from table/database (remotely) ??? can you give me an example???


Title: Re: SearchBox Category Load From Table/Database
Post by: jarry on July 24, 2018, 02:24:27 AM
The code below shows how to create a menu programmatically and attach it to the searchbox component.
Code:
// retrieve data from server
var menus = [
{name:'all',text:'All News'},
{name:'sports',text:'Sports News'}
];
// create the menu
var mm = $('<div></div>').appendTo('body');
mm.menu();
for(var i=0; i<menus.length; i++){
mm.menu('appendItem', menus[i]);
}
// attach the menu to the searchbox
$('#sb').searchbox({menu:mm})