Click here to Skip to main content
15,885,980 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
$(document).ready(function () {
        var pageIndex = 1;
        var pageCount;
        var minCarat = $("#carat-min").val();
        var maxCarat = $("#carat-max").val();
        debugger;
        $("#gvJQGrid").jqGrid({
            //url: 'http://192.168.108.33/Diamond/default.aspx?jqGridID=JQGrid1',
            url: 'SampleDefault.aspx/GetCustomers',
            data: JSON.stringify({ 'pageIndex': pageIndex, 'mincart': minCarat, 'maxcart': maxCarat }),
            contentType: "application/json; charset=utf-8",
            mtype: "GET",
            datatype: "json",
            page: 1,
            colNames: ['Images', 'Compare', 'Shape', 'Carat', 'Cut', 'Color', 'Clarity', 'Polish', 'Symmetry', 'Depth', 'Table', 'Floroscence',
                       'Price_Ct', 'Culet', 'Details'],
            colModel: [
                         {
                             name: 'Images',
                             align: 'center',
                             formatter: formatImage
                         },
                         {
                             name: 'checkbox',
                             align: 'center',
                             formatter: formatChkbox,

                         },
                         { name: 'Shape', align: 'center' },
                         { name: 'Carat', align: 'center'},
                         { name: 'Cut1', align: 'center' },
                         { name: 'Color1', align: 'center' },
                         { name: 'Clarity', align: 'center' },
                         { name: 'Polish1', align: 'center' },
                         { name: 'Symmetry1', align: 'center' },
                         { name: 'Depth1', align: 'center' },
                         { name: 'Table_1', align: 'center' },
                         { name: 'Floroscence1', align: 'center' },
                         { name: 'Price_Ct1', align: 'center' },
                         { name: 'Culet1', align: 'center' },
                         {
                             name: 'View',
                             align: 'center',
                             formatter: formatButton
                         }
            ],
            width: 840,
            height: 500,
            rowNum: 20,
            scroll: 1, // set the scroll property to 1 to enable paging with scrollbar - virtual loading of records
            emptyrecords: 'Scroll to bottom to retrieve new page', // the message will be displayed at the bottom
            pager: "#jqGridPager"
        });
    });

    function formatImage(cellValue, options, rowObject) {
        var imageHtml = "<img src='images/" + cellValue + "' originalValue='" + cellValue + "' />";
        return imageHtml;
    }

    function formatChkbox(cellValue, options, rowObject) {
        var imageHtml = "<input type=checkbox />";
        return imageHtml;
    }

    function formatButton(cellValue, options, rowObject) {
        var imageHtml = "<a href = # >View</a>";
        return imageHtml;
    }


    // The FormatFunction for CustomFormatter gets three parameters
    // cellValue - the original value of the cell
    // options - as set of options, e.g
    //   options.rowId - the primary key of the row
    //   options.colModel - colModel of the column
    // cellObject - the HMTL of the cell (td) holding the actual value
    function unformatImage(cellValue, options, cellObject) {
        return $(cellObject.html()).attr("originalValue");
    }
Posted
Comments
Have you debugged? Is there any error listed on Browser Console?
Member 9340623 29-Jan-15 23:07pm    
Yes debugged but not getting any error.
Member 9340623 29-Jan-15 23:20pm    
JQgrid doesn't have records it come empty please help.
Put a break point on your method "GetCustomers" and then debug to see what is happening inside that. Whether that method is returning data or not.
Member 9340623 30-Jan-15 1:22am    
ReferenceError: GetCustomers is not defined

1 solution

[[[ Taking the discussion from comments to this answer as Reply Button is not visible and comment box is also very small. ]]]

Okay, so do like below for one parameter.
JavaScript
mtype: "POST",

JavaScript
data: JSON.stringify({ pageIndex: pageIndex }),

C#
[WebMethod]
public string HelloWorld(string pageIndex)
{
    return "Hello World";
}
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900