0

I am using EditableGrid (http://www.editablegrid.net/) Which creates some nice looking Editable tables

I'm Trying to modify the table header to make them into Individual filters like in example - https://phppot.com/demo/column-search-in-datatables-using-server-side-processing/

Current Filter textbox works very nicely but has a limit for searching one value for all columns.

I find many solutions for an individual column filter but I don't want to use other tables as they do not provide inline table editing functionality with dropdown and date picker, Is there a way I can implement it in EditableGrid?

I have also Asked this Question on Github (https://github.com/webismymind/editablegrid-mysql-example/issues/66) but the thread is not been active for a long time so I have very little hope of getting a solution from there.

1 Answers1

0

In index.html update this code: see where //new code ---- starts and //new code ---- ends, try it out..

<script type="text/javascript">

                var datagrid; 

                window.onload = function() { 
                  datagrid = new DatabaseGrid();

//new code ---- starts 

var list = document.getElementsByTagName("thead")[0];
for(var i = -1; i < list.childNodes.length; i++){

    var input = document.createElement("input");
                input.type = "text";
                input.className = "filter";
  list.getElementsByTagName("th")[i+1].appendChild(input);
}
var z = document.getElementsByClassName('filter')
for(var i = 0; i< z.length; i++){
  z[i].addEventListener("input", function(e){      

  datagrid.editableGrid.filter( e.target.parentNode.querySelector("input").value, [i]);
  })
}  

//new code ---- ends

                    // key typed in the filter field
                    $("#filter").keyup(function() {
                      datagrid.editableGrid.filter( $(this).val());
                        // To filter on some columns, you can set an array of column index 
                        //datagrid.editableGrid.filter( $(this).val(), [0,3,5]);
                      });
                    $("#showaddformbutton").click( function()  {
                      showAddForm();
                    });
                    $("#cancelbutton").click( function() {
                      showAddForm();
                    });
                    $("#addbutton").click(function() {
                      datagrid.addRow();
                    });


        } 
    $(function () { 
        });
            </script>
Stefan Avramovic
  • 1,365
  • 2
  • 11
  • 20
  • That's the problem editablegrid Index page do not have TD TH tags table is creating a under
    tag (https://github.com/webismymind/editablegrid-mysql-example/blob/master/index.html)
    – yatendra singh ranawat Feb 24 '19 at 20:19
  • that shuld not be an issue – Stefan Avramovic Feb 24 '19 at 20:23
  • ok so if I put this function init() in HTML page it will work? i have to put somwhare right. – yatendra singh ranawat Feb 24 '19 at 20:25
  • input fields with class=”filter” gos in to table header, all that oather html like you can skipp – Stefan Avramovic Feb 24 '19 at 20:33
  • Did you have chance to look at the Coding of editable grid (https://github.com/jybeaujean/editablegrid-mysql-example) i think you might able to help me after you know the editablegrid structure. Thank you for investing you time to try to help me. – yatendra singh ranawat Feb 24 '19 at 20:54
  • The search box on the header is not being generated (https://i.imgur.com/4mc2mDF.jpg) do I missing something ? – yatendra singh ranawat Feb 25 '19 at 08:45
  • Can you pass source code of the page, right click on page "show page source" so i can see how table is generated. – Stefan Avramovic Feb 25 '19 at 09:57
  • Sure, there is the link - (https://github.com/yatendra3192/editablegrid-column-filter/blob/master/Index.html) I think the table is generating between
    tag You can get all the dependent code here my table is the exact copy of it (https://github.com/webismymind/editablegrid-mysql-example)
    – yatendra singh ranawat Feb 25 '19 at 11:57
  • Yes i know, but when you execute the code in the browser a new code gets compiled, there you can see the structure of the table that has been generated. Open the page in your browser.. Right click and go to inspect or view page source https://merabheja.com/wp-content/uploads/2016/03/1rightClick-1.png – Stefan Avramovic Feb 25 '19 at 12:36
  • Yes, I understand what you trying to do here and the code looks correct i have no idea why it's not working. – yatendra singh ranawat Feb 25 '19 at 15:30
  • Thank you so much bro for all the efforts. Let me know if you find any solution for this in the future. – yatendra singh ranawat Feb 25 '19 at 17:21