Click here to Skip to main content
15,887,376 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi friends..

I am facing one problem that is in success function i am geting the data but how to show that data on the page using jquery i have done some code for this.
JavaScript
$(document).ready(function () {
        //Dropdownlist Selectedindexchanged 
        $('#lstAsgname').change(function () {
           // alert($('#lstAsgname').val());
            $.ajax({
                url: "DropDown/DdlSelectedIndex",
                type:'post',
                success: function (data) {
                    debugger;
                    $("#ProjectTable").jqGrid({
                        datatype: 'json',
                        mtype: 'GET',
                        colNames: ['ID', 'Name', 'Status', 'Category'],
                        height: 500,
                        pager: jQuery('#pager'),

                        jsonReader: {
                            root: "rows",
                            //array containing actual data   
                            page: "page",
                            //current page  
                            total: "total",
                            //total pages for the query  
                            records: "records",
                            //total number of records  
                            repeatitems: false,
                            id: "ID"
                            //index of the column with the PK in it   
                        },
                        colNames: ['ID', 'Name', 'Status', 'Category'],
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        colModel: [
                                    { name: 'ID', index: 'ID', width: 40, height: 100, align: 'left' },
                                    { name: 'Name', index: 'Name', width: 400, height: 100, align: 'left' },
                                    { name: 'Status', index: 'Status', width: 100, height: 100, align: 'left' },
                                    { name: 'Category', index: 'Category', width: 300, height: 100, align: 'left'}],
                        sortname: 'ID',
                        sortorder: "desc",
                        viewrecords: true,
                        caption: 'Team Fourm'
                    });
                  
                }
            });
        })
    });

Please help me to solve this issue.....

Thanks
Posted
Updated 13-Jan-13 23:45pm
v4

1 solution

Hi,

I had the same problem and I solved that problem. Here is my code you can verify that and you will able to know your fault.

<script type="text/javascript" language="javascript">

        $(document).ready(function () {
            try {
                $("#tableGroup").jqGrid({
                    height: 'auto',
                    width: 'auto',
                    contentType: 'application/json; charset=utf-8',
                    mtype: 'POST',
                    url: 'Project.aspx',
                    datatype: 'json',
                    postData: {
                        id: function () { return 'jqGrid'; },
                        date: function () { return jQuery("#<%=hfDate.ClientID%>").val(); },
                        userName: function () { return jQuery("#<%=hfUserName.ClientID%>").val(); }

                    },

                    jsonReader: {
                        root: "rows",
                        page: "page",
                        total: "total",
                        records: "records",
                        repeatitems: true,
                        cell: "cell",
                        id: "id",
                        userdata: "userdata"
                    },

                    colNames: ['Name', 'ProjectName', 'ProjectBA', 'ProjectAD', 'PriorityOrder', 'JIRA#', 'Title', 'Priority', 'Complexity', 'Status',
                                'Clarity', 'InitialEstimate', 'RemainingEstimate', 'TimeSpent', 'OverallProject%', 'Comments', ''],
                    colModel: [
                                { name: 'Name', index: 'Name', width: 120, sortable: true, editable: true, resizable: true, hidden: false },
                                { name: 'ProjectName', index: 'ProjectName', width: 100, align: "left", sortable: true, editable: true, resizable: true, hidden: false },
                                { name: 'ProjectBA', index: 'ProjectBA', width: 100, align: "left", sortable: true, editable: true, resizable: true, hidden: false },
                                { name: 'ProjectAD', index: 'ProjectAD', width: 100, align: "left", sortable: true, editable: true, resizable: true, hidden: false },
                                { name: 'PriorityOrder', index: 'PriorityOrder', sorttype: Number, width: 100, sortable: false, editable: false, resizable: false, hidden: false },
                                { name: 'JIRA#', index: 'JIRA#', width: 100, sorttype: Number, align: "left", sortable: true, editable: true, resizable: true, hidden: false },
                                { name: 'Title', index: 'Title', width: 150, align: "left", sortable: true, editable: true, resizable: true, hidden: false },
                                { name: 'Priority', index: 'Priority', width: 50, align: "left", sortable: false, editable: true, resizable: true, hidden: false },
                                { name: 'Complexity', index: 'Complexity', width: 50, align: "left", sortable: false, editable: true, resizable: true, hidden: false },
                                { name: 'Status', index: 'Status', width: 50, align: "left", sortable: false, editable: true, resizable: true, hidden: false },
                                { name: 'Clarity', index: 'Clarity', width: 50, align: "left", sortable: false, editable: true, resizable: true, hidden: false },
                                { name: 'InitialEstimate', index: 'InitialEstimate', width: 50, align: "left", sortable: false, editable: false, resizable: true, hidden: false },
                                { name: 'RemainingEstimate', index: 'RemainingEstimate', width: 50, align: "left", sortable: false, editable: false, resizable: true, hidden: false },
                                { name: 'TimeSpent', index: 'TimeSpent', width: 50, align: "left", sortable: false, editable: false, resizable: true, hidden: false },
                                { name: 'OverallProject%', index: 'OverallProject%', width: 50, align: "left", sortable: false, editable: false, resizable: true, hidden: false },
                                { name: 'Comments', index: 'Comments', width: 200, align: "left", sortable: true, editable: true, resizable: true, hidden: false },


                                { name: 'ProjectID', index: 'ProjectID', width: 75, sortable: true, editable: false, resizable: true, hidden: true }
   	                          ],
                    rowNum: 30,
                    rowList: [10, 15, 20, 30, 50, 100, 200, 300, 500, 750, 1000],
                    pager: $('#divGroupPager'),
                    sortname: 'ProjectName',
                    sortorder: "desc",
                    loadtext: "Loading....",
                    autowidth: false,
                    shrinkToFit: false,
                    emptyrecords: "No matching records to view",
                    rownumbers: false,
                    loadonce: true,
                    gridComplete: function () {
                    },
                    rownumWidth: 30,
                    toolbar: [true, "both"],
                    recordpos: 'left',
                    viewrecords: true,
                    caption: "DSR Report"
                });

                $("#tableGroup").jqGrid('navGrid', '#divGroupPager', { edit: true, add: false, del: false, excel: true });
                //$("#tableGroup").jqGrid('searchGrid', { sopt: ['cn', 'bw', 'eq', 'ew'] });               

            } catch (e) {
                alert(e);
            }
        });

    </script>


Thanks
 
Share this answer
 

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