2013-03-07 204 views

回答

0

不知道,如果你還在尋找,但這裏是一個使用HTML的解決方案,jQuery的/ jeasyui/AJAX和Java:

  1. HTML:

    <html>
    <form>
    <input id="searchFilter" name="searchFilter" class="required" />
    <a href="#" onclick="doSearch()">Search</a>
    </form>
    <%-- the treegrid (a table) to contain the results --%>
    <table id="dgMilestone"></table>
    <html>

  2. Jeasyui /阿賈克斯。這被放置在相同的文件如上述的HTML代碼:

    <script type="text/javascript">
    $('#dgMilestone').treegrid({
    url:"yourBean.action?&listAjax",
    idField:'id',
    refresh:'id',
    treeField:'name',
    columns:[[
    {field:'name',title:'Name',width:250, rowspan:2, sortable:'true'},
    ]]

    });

    function doSearch() {
    // get the search parameter
    var search = $('#searchFilter').val();
    // call your backing bean method, passing the search filter
    $('#dgMilestone').treegrid({
    url:'yourBean.action?&_eventName=searchAjax&searchFilter='+search });
    }
    </script>

我沒有包括後端ST uff,但是在你的支持bean中,你會有一個名爲searchAjax的方法,它獲取searchFilter參數,然後調用服務層,並將參數作爲參數傳遞給搜索方法。

結果(一個集合)從服務層返回到支持bean,它將它們轉換爲JSON(也未顯示),然後doSearch()重新繪製treegrid以顯示找到的結果