Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
filter functionality is not working in jqgrid
07/10/2014
17:36
Avatar
mcfarland
Member
Members
Forum Posts: 11
Member Since:
07/10/2014
sp_UserOfflineSmall Offline

Hi,

    i have a jqgrid which populates data form database.when i click on name header to search particular name and press enter it will give only those records with the searched name.now i want to export to excel that filter names.while exporting its giving all the rows in the grid not the filter records which i searched with particular name not sure where i am doing wrong.

here is my code..

$("#list").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true, defaultSearch: "cn" }).navButtonAdd('#pager', {caption:"Export to Excel",

buttonicon:"ui-icon-disk",

onClickButton:function() {

ExportDataToExcel("#list");

},

position:"last"

});

 

function ExportDataToExcel(tableCtrl) {

ExportJQGridDataToExcel(tableCtrl,"View.xlsx");

}

 

function ExportJQGridDataToExcel(tableCtrl, excelFilename) {
   
    var allJQGridData = $(tableCtrl).jqGrid('getGridParam', 'data');

    var jqgridRowIDs = $(tableCtrl).getDataIDs();              
    var headerData = $(tableCtrl).getRowData(jqgridRowIDs[0]);   // Fetch the list of "name" values in our colModel

 
    var columnNames = new Array();      
    var columnHeaders = new Array();    
    var inx = 0;
    var allColumnNames = $(tableCtrl).jqGrid('getGridParam', 'colNames').slice();
    allColumnNames.splice(0, 1);

    for (var headerValue in headerData) {
      
        var isColumnHidden = $(tableCtrl).jqGrid("getColProp", headerValue).hidden;
        if (!isColumnHidden && headerValue != null) {
            columnNames.push(headerValue);
            columnHeaders.push(allColumnNames[inx]);
        }
        inx++;
    }

  
    var excelData = '';
    for (var k = 0; k < columnNames.length; k++) {
        excelData += columnHeaders[k] + "\t";
    }
    excelData = removeLastChar(excelData) + "
";

 
    var cellValue = '';
    for (i = 0; i < allJQGridData.length; i++) {

        var data = allJQGridData[i];

        for (var j = 0; j < columnNames.length; j++) {

          
            cellValue = '' + data[columnNames[j]];

            if (cellValue == null)
                excelData += "\t";
            else {
                if (cellValue.indexOf("a href") > -1) {
                 
                    cellValue = $(cellValue).text();
                }
               
                cellValue = cellValue.replace(/'/g, "&apos;");

                excelData += cellValue + "\t";
            }
        }
        excelData = removeLastChar(excelData) + "
";
    }

 
    postAndRedirect("Helpers/ExportGridToExcel.ashx?filename=" + excelFilename, { excelData: excelData });
}

21/10/2014
17:20
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

 

This is know problem.

Unfortunately this is not supported at the moment. 

You can use the build-in manipulating with local data in grid, but I think it is a little bit complex.

 

Regards

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
46 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information