Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am using jqgrid in my project there is requirement,when a cell is select in gridview different other fields in webpage will fill so i am using a web method that return a list but problem is that on cellclick,command is not going to aspx.cs page

JavaScript
<script type="text/javascript">
        $(function () {            
            var appsurl = '<%=ConfigurationManager.AppSettings["localpath"].ToString() %>';
            var urlpath = appsurl + 'GetAllLeaveAdjustmentRetirementView';
            "use strict";
            var oItemGrid = $("#UsersGrid");
            oItemGrid.jqGrid({
                url: urlpath,
                mtype: "GET",
                datatype: "json",
                ajaxGridOptions: {
                    contentType: "application/json"
                },
                serializeGridData: function (data) {
                    return JSON.stringify(data);
                },
                colNames: ['','Application No.', 'Date', 'Employee Name', 'Department', 'Designation', 'Date Of Retirement',''],
                colModel: [
                    {
                        name: 'enbl', index: 'enbl', width: 20, align: 'center',
                        formatter: 'checkbox', editoptions: { value: '1:0' },
                        formatoptions: { disabled: false }
                    },
                    { name: 'RetirementProposalNo', index: 'RetirementProposalNo', width: 90 },
                           { name: 'DateOfJoining', index: 'DateOfJoining', width: 90 },
                           { name: 'EmployeeName', index: 'EmployeeName', width: 100 },
                           { name: 'Department', index: 'Department', width: 120 },
                           { name: 'Designation', index: 'Designation', width: 90 },
                           { name: 'DateOfRetirement', index: 'DateOfRetirement', width: 90 },                           
                            { name: 'EmpPorfessionalId', index: 'EmpPorfessionalId', hidden: true }
                ],
                autowidth: true,
                height: 'auto',
                rowNum: 10,
                rowList: [10, 20, 30],
                pager: '#pager1',
                sortname: 'Department',
                loadonce: true,
                viewrecords: true,
                sortorder: "desc",
                rownumbers: true,
                onCellSelect: function (row, col, content, event) {
                    //alert("amit");
                    Id = jQuery("#UsersGrid").jqGrid('getCell', row, 'EmpPorfessionalId');
                    FillDetails(Id);
                    //window.location.href="/KB/answers/HRMS_LeaveAdjustmentAdd.aspx"?id=" + content;
                   
                },

                jsonReader: {
                    root: "d"

                }

            });
            // Edit and display //



            jQuery("#UsersGrid").jqGrid('navGrid', '#pager1', { edit: false, add: false, del: false }, {}, {}, {}, { multipleSearch: true, multipleGroup: true, showQuery: true, closeAfterSearch: true });
        });
        function FillDetails(Id) {
            alert("amit");
            alert(Id);
            debugger;
            $.ajax({
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: "HRMS_LeaveAdjustmentView.aspx/FillDetails",
                data: '{Id : "' + Id + '" }',
                dataType: "json",
                success: function (data) {
                    $.each(data, function (index, emprs) {
                        $('#ContentPlaceHolder1_lblFinalDecision').val(emprs.FinalDecission);
                        $('#ContentPlaceHolder1_lblChargesHandedFrom').val(emprs.ChargesHandedOverFrom);
                        $('#ContentPlaceHolder1_lblRetirementProposalNo').val(emprs.RetirementProposalNo);
                        $('#ContentPlaceHolder1_lblRetirementProposalDate').val(emprs.RetirementProposalDate);
                        $('#ContentPlaceHolder1_lblRetirementDate').val(emprs.DateofRetirement);
                        $('#ContentPlaceHolder1_lblJobType').val(emprs.JobType);
                        $('#ContentPlaceHolder1_lblDepartment').val(emprs.DepartmentName);
                        $('#ContentPlaceHolder1_lblDesignation').val(emprs.DesignationName);
                        $('#ContentPlaceHolder1_lblAppointmentDate').val(emprs.DateOfAppointment);
                        $('#ContentPlaceHolder1_lblScaleCode').val(emprs.ScaleCode);
                    });

                },
                failure: function (response) {
                    alert(response.d);
                }
            });           
        }
        function OnSuccess(response) {
            alert("done");
        }
    </script>


and my aspx.cs page is like this,i have a web method that return a list

C#
[WebMethod]
        public static List<Details> FillDetails(int Id)
        {
}
Posted
Updated 6-May-14 1:11am
v2
Comments
Sunasara Imdadhusen 6-May-14 8:24am    
Can you please provide more details on the same!!

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