gopendra-dwivedi / jquery-datatables-column-filter

Automatically exported from code.google.com/p/jquery-datatables-column-filter
0 stars 0 forks source link

Problem with sPlaceHolder #129

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
this is my code:

    $.ajax({
        type:"GET",
        url:"user.json",
        dataType:"json",
        success:function(data){
            oTable = $('#example').dataTable({
                "iDisplayLength": 10,
                "sDom": 'l<"tools">frtip',
                "aaData":data,
                "aoColumns": [
                    { "mData": "DisplayName","sTitle":"DisplayName","fnRender": 
                        function(obj){ return "<a href='#'> "+obj.aData.DisplayName.toString()+"</a>";} },
                    { "mData": "Email","sTitle":"Employee Email" },
                    { "mData": "Manager","sTitle":"Manager"},
                    { "mData": "PrimaryGroup","sTitle":"PrimaryGroup"},
                    { "mData": "SubmitDate","sTitle":"Submit Date","sType": "date-sort","fnRender":function(obj){
                        if (!obj.aData.SubmitDate) { return " -- "; }
                        var date1 = new Date(Date.parse((obj.aData.SubmitDate.toString().substring(0, 10) + " 00:00:00").replace(/-/g, "/")));
                        return date1.pattern("dd/MM/yyyy");
                    }},
                    { "mData": "Description","sTitle":"Description"}
                ],
                "fnInitComplete": function() { /* Auto setting columns */
                                aoCols = new Array()
                                var oSettings = $('#example').dataTable().fnSettings();
                                for( var i=0; i < oSettings.aoColumns.length; i++){
                                    var col = oSettings.aoColumns[i];
                                    if(col){
                                        aoCols.push(col.mData);
                                    }
                                }
                            }
            });

            oTable.columnFilter({
                sPlaceHolder: "head:after",
                aoColumns:[
                            {type:"select",values:["Marc","Mini"]},
                            {type:"text"},
                            {type:"text"},
                            {type:"text"},
                            {type:"text"},
                            {type:"text"}
                        ]
            });

As you see, the setting is sPlaceHolder: "head:after".
but i can't get the result like:
https://jquery-datatables-column-filter.googlecode.com/svn/trunk/dateRange.html 

Please refer to the attachments,you will see the table header has problem to 
display ,please help me,thank you!

Original issue reported on code.google.com by KaleyRoy on 17 Jul 2013 at 4:23

Attachments:

GoogleCodeExporter commented 9 years ago
html:

        <table cellpadding="0" cellspacing="0" border="0"  style="width:100%;" id="example">
            <thead>
                <tr>
                    <th>DisplayName</th>
                    <th>Email</th>
                    <th>Manager</th>
                    <th>PrimaryGroup</th>
                    <th>SubmitDate</th>
                    <th>Description</th>
                </tr>
                <tr>
                    <th>DisplayName</th>
                    <th>Email</th>
                    <th>Manager</th>
                    <th>PrimaryGroup</th>
                    <th>SubmitDate</th>
                    <th>Description</th>
                </tr>

            </thead>

        </table>

Original comment by KaleyRoy on 17 Jul 2013 at 4:28

GoogleCodeExporter commented 9 years ago
Oh,sorry.
this problem like issue24
https://code.google.com/p/jquery-datatables-column-filter/issues/detail?id=24

solution:

//Line:252
            if (properties.sPlaceHolder == "head:after") {
                //sFilterRow = "thead tr:last";

                var tr = $("thead tr:last", oTable).detach();
                tr.prependTo($("thead", oTable));
                sFilterRow = "thead tr:last";               
            } else if (properties.sPlaceHolder == "head:before") {
                var tr = $("thead tr:last").detach();
                tr.prependTo("thead");
                sFilterRow = "thead tr:first";
            }

Original comment by KaleyRoy on 17 Jul 2013 at 4:50