Skip to content Skip to sidebar Skip to footer

Displaying Data Of Datatable Column

I am using the jQuery DataTables plugin on a JSF . In this page I have 86 records. +++++++++++++++++++++++++++++++++++++ + SN. + Name + Email + +

Solution 1:

Well, this is what I did...

<scripttype="text/javascript">
    $(document).ready(function(){
        var currData = [];
        var myFinalString = "";

        $('#userList').dataTable( {
            "bPaginate": true,
            "bSort": true,
            "sPaginationType": "full_numbers",
            "bJQueryUI": true,
            "bRetrieve": true,
            "fnPreDrawCallback": function(oSettings) {
                /* reset currData before each draw*/
                currData = [];
                myFinalString= "";
            },
            "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                   /* push this row of data to currData array*/
                   currData.push(aData);
                   myFinalString = myFinalString + aData + "xxxyyyzzz";
            },
            "fnDrawCallback": function () {

                var myTextBox2 = document.getElementById('myHiddenValForId');
                myTextBox2.value = myFinalString;
                myTextBox2.onchange();

                var myTextBox = document.getElementById('myHiddenValForInc');
                myTextBox.value = this.fnPagingInfo().iStart + "," + this.fnPagingInfo().iEnd;
                myTextBox.onchange();

                var cells = [];
                var cells2 = [];
                oTable = $('#userList').dataTable();

                var rows = $("#userList").dataTable().fnGetNodes();

                for(var i=0;i &lt; rows.length;i++) {
                    var data = oTable.fnGetData( i,0 );
                    cells.push($(rows[i]).find("td:eq(0)").html()); 
                    cells2.push(data); 
                }

                var secondCellArray = [];
                $.each(oTable.fnGetData(), function(i, row) {
                    secondCellArray.push(row[0]);
                });
            }
        });
    });
    $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
    {
        return {
            "iStart":         oSettings._iDisplayStart,
            "iEnd":           oSettings.fnDisplayEnd(),
            "iLength":        oSettings._iDisplayLength,
            "iTotal":         oSettings.fnRecordsTotal(),
            "iFilteredTotal": oSettings.fnRecordsDisplay(),
            "iPage":          oSettings._iDisplayLength === -1 ?
                0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
            "iTotalPages":    oSettings._iDisplayLength === -1 ?
                0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
        };
    };
</script>

Pass those values through f:ajax

<h:formprependId="false"><h:inputTextid="myHiddenValForInc"value="#{SearchBean.hiddenVal001}"style="display: none;"><f:ajaxlistener="#{SearchBean.printMyHiddenDetails()}"event="valueChange" /></h:inputText><h:inputTextid="myHiddenValForId"value="#{SearchBean.hiddenVal002}"style="display: none;" ><f:ajaxlistener="#{SearchBean.printMyHiddenDetails2()}"event="valueChange" /></h:inputText></h:form>

.java

`printMyHiddenDetails()` have all stuff for finding names & `printMyHiddenDetails2()` don't have any code


publicvoidprintMyHiddenDetails(){
    // my code
}


publicvoidprintMyHiddenDetails2(){
    // noting here... this is just for passing data...
}

Post a Comment for "Displaying Data Of Datatable Column"