tabalinas / jsgrid

Lightweight Grid jQuery Plugin
http://js-grid.com
MIT License
1.53k stars 353 forks source link

loadData not refreshing grid. #1402

Open tbauserman opened 2 years ago

tbauserman commented 2 years ago

I have a textbox outside of my grid that I'm trying to use to filter the grid. I can get it to fire and it's making it to the "myReload" function. It looks like the mp_search isn't being sent. Maybe there's a better way to do this. I want to load the initial data with all results. Then as they type in the search box have it reload the data from the server using that search term matching against multiple fields.

`var mp_grid = $('#mp_grid').jsGrid({ width: "900px", height: "auto", autoload: true, inserting: false, editing: false, sorting: true, paging: true,
pageSize: 20, pageButtonCount: 5, pageIndex: 1, controller: { loadData: function(filter){ App = {}; App.loadUrl = 'process/get_mp.php'; return $.ajax({ type: "GET", dataType: "json", url: App.loadUrl, }) } }, fields: [ {name:"id",type:"hidden",css:"hide"}, {name:"dba",type:"text",width:40,title:"DBA"}, {name:"legal",type:"text",width:40,title:"Legal"}, {name:"license",type:"number",width:9,title:"IGB"}, {name:"site_code",type:"number",width:4,title:"BMC"}, {name:"number",type:"number",width:1,title:"MP #"}, {name:"video",type:"text",width:40,title:"Video"}, {name:"online",type:"text",width:1,title:"OnLine"} ] });

        var myReload = function(obj) {  
            $('#mp_grid').jsGrid('loadData',{ mp_search: $(obj).val() }); 
        }
        var keyupHandler = function(e,refreshFunction,obj) {
            var keyCode = e.keyCode || e.which;
            if (keyCode === 33 /*page up*/|| keyCode === 34 /*page down*/||
            keyCode === 35 /*end*/|| keyCode === 36 /*home*/||
            keyCode === 38 /*up arrow*/|| keyCode === 40 /*down arrow*/) {}
                if (typeof refreshFunction === "function") {
                    refreshFunction(obj);
                }
        }

        $('#mp_search').change(myReload).keyup(function(e){ 
            keyupHandler(e,myReload,this); 
        });`
tbauserman commented 2 years ago

Forgot to mention I am getting the value of mp_search in the myReload function.