给easyui datagrid添加搜索栏

最近使用easyui,发现datagrid默认toolbar没有搜索输入栏,通过反复实验终于添加上了,分享给各位。先上图看一下效果 函数


$("<td style='padding: 0 8px;'><input class='easyui-searchbox' style='width: 200px;' " +
                "prompt='请输入姓名或拼音查询' searcher='person.search'></td>").
                prependTo(".datagrid-toolbar table tbody tr");

var person = {
        search: function (value) {
            $("#personList").datagrid("load", {
                index: value
            });
        }
}
很简单吧,能够用回车键触发搜索函数