EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: karogel on August 24, 2015, 12:45:55 AM



Title: category search box
Post by: karogel on August 24, 2015, 12:45:55 AM
I'm using mysql as database. I'm trying to use datagrid with category searchbox but of no luck. please post me complete sample code including sql query to mysql. Thank you


Title: Re: category search box
Post by: stworthy on August 24, 2015, 01:00:13 AM
The sample code below is extended from http://www.jeasyui.com/demo/main/index.php?plugin=SearchBox&theme=default&dir=ltr&pitem=Search%20Category
Code:
<input class="easyui-searchbox" data-options="prompt:'Please Input Value',menu:'#mm',searcher:doSearch" style="width:300px"></input>
<div id="mm">
    <div data-options="name:'all',iconCls:'icon-ok'">All News</div>
    <div data-options="name:'sports'">Sports News</div>
</div>
<script>
    function doSearch(value,name){
        var dg = $('#dg');  // the datagrid
        dg.datagrid('load', {  // reload the datagrid data by passing the 'q' and 'category' parameters to server
            q: value,
            category: name
        });
    }
</script>


Title: Re: category search box
Post by: karogel on August 24, 2015, 01:37:06 AM
do have online demo of this:
<input class="easyui-searchbox" data-options="prompt:'Please Input Value',menu:'#mm',searcher:doSearch" style="width:300px"></input>
<div id="mm">
    <div data-options="name:'all',iconCls:'icon-ok'">All News</div>
    <div data-options="name:'sports'">Sports News</div>
</div>
<script>
    function doSearch(value,name){
        var dg = $('#dg');  // the datagrid
        dg.datagrid('load', {  // reload the datagrid data by passing the 'q' and 'category' parameters to server
            q: value,
            category: name
        });
    }
</script>
please post. thank you