Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi here is client side code
JavaScript
<script src="Scripts/jquery-1.6.2.js" type="text/javascript"></script>
<script src="JavaScript/grid.locale-en.js" type="text/javascript"></script>
<script src="JavaScript/jquery.jqGrid.min.js" type="text/javascript"></script>
    <script src="JavaScript/json2-min.js" type="text/javascript"></script>
<script type="text/javascript">
    function successFunction(jsondata, a) {
  var thegrid = jQuery("#productGridView")[0];
        var data = JSON.stringify(jsondata);
       thegrid.addJSONData(JSON.parse(data));

    }
  function getProducts() {

        var PolicyNumberorClaim = $("#txtPolicyNum").val();
        var PolicyNum = { PolicyNo: PolicyNumberorClaim };


        $.ajax({
            url: "Service/RGIService.svc/ServiceRequestListByPolNumber",
            data: JSON.stringify(PolicyNum),  // For empty input data use "{}",
            dataType: "json",
            type: "POST",
            contentType: "application/json; charset=utf-8",
            success: successFunction
        });
    }

    function dataBindToGrid() {
        jQuery("#productGridView").jqGrid({
            datatype: getProducts,
            colNames: ['SRNo', 'ClaimNo', 'SubCategory', 'PolicyNumber', 'ExpectedClosureDateSpecified'],
            colModel: [{ name: 'SRNo', index: 'SRNo', width: 200, align: 'left' },
                        { name: 'ClaimNo', index: 'ClaimNo', width: 200, align: 'left' },

                        { name: 'SubCategory', index: 'SubCategory', width: 200, align: 'left' },
                        { name: 'PolicyNumber', index: 'PolicyNumber', width: 200, align: 'left' },
                        { name: 'ExpectedClosureDateSpecified', index: 'ExpectedClosureDateSpecified', width: 200, align: 'left' }
                       ],
            rowNum: 10,
            rowList: [5, 10, 20, 50, 100],
            sortname: 'SRNo',
            pager: jQuery('#pageNavigation'),
            sortorder: "desc",
            viewrecords: true
        });
    }
    $(document).ready(function () {

        $("input#LoadData").live("click", dataBindToGrid);
    });
</script>
<link rel="stylesheet" type="text/css" media="screen" href="css/redmond/jquery-ui-1.7.2.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />


<div>
        <table id="productGridView" class="scroll">
        </table>
        <input type="text" name="PolicyNumber" placeholder="Enter Policy Number" id="txtPolicyNum"
            maxlength="16" />
        <div id="pageNavigation" class="scroll" style="text-align: center;">
        </div>
        <input type="button" id="LoadData" value="LoadData"  önclick="dataBindToGrid();" />
       
    </div>

and the service code will be
C#
public string ServiceRequestListByPolNumber(String PolicyNo)
{
    PortalService.ServiceRequestDetails[] objPolicyDetails = new PortalService.ServiceRequestDetails[0];
    List<string> objString = new System.Collections.Generic.List<string>();
    List<SelectList> list = new List<SelectList>();
    try
    {
        PortalService.WCFServiceClient obj = new PortalService.WCFServiceClient();
       PortalService.WCFServiceClient();

        objPolicyDetails = obj.GetServiceRequestListByPolicyNo(PolicyNo);
        List<rgipolicydetails> lstpol = new System.Collections.Generic.List<rgipolicydetails>();
        RGIPolicyDetails pol = new RGIPolicyDetails();
        foreach (PortalService.ServiceRequestDetails sr in objPolicyDetails)
        {

            pol.ClaimNo = sr.Category;
            pol.CreateDate = sr.CreateDate.ToString();
            pol.ExpectedClosureDate = sr.ExpectedClosureDate.ToString();
            pol.ExpectedClosureDateSpecified = sr.ExpectedClosureDateSpecified.ToString();
            pol.PolicyNumber = sr.PolicyNumber;
            pol.SRNo = sr.SRNo;
            pol.SubCategory = sr.SubCategory;
        }
        return pol.TOJSON();
    }
    catch (Exception ex)
    {
        return null;
    }
}

and the class will be
C#
public abstract class JqGridView
{

    public abstract string ToJson();
}

public  class RGIPolicyDetails 
{
    public string PolicyNo { get; set; }
    public string InsuredNameFore { get; set; }
    public string InsuredNameLast { get; set; }
    public string PolicyPeriod{ get; set; }
    public string VehiceMakeorModel{ get; set; }
      public string  VehicleNumber{ get; set; }
      public string PolicyCoverFrom { get; set; }
      public string PolicyCoverTo { get; set; }

       public string   ClaimNo{ get; set; }
    public string CreateDate{ get; set; }
    public string ExpectedClosureDate{get;set;}
        public string  ExpectedClosureDateSpecified{ get; set; }
         public string     PolicyNumber{ get; set; }

           public string   SRNo{ get; set; }
           public string SubCategory { get; set; }
           public string status { get; set; }

        
}

C#
public static class methodtest 
{
       public static string TOJSON(this object obj)
{

JavaScriptSerializer serializer=new JavaScriptSerializer();
return serializer.Serialize(obj);
}
        
}

can any one suggest me where i am going wrong
Posted
Updated 29-Jun-12 0:48am
v2
Comments
Christian Graus 14-Aug-12 21:18pm    
you need to tell us what is happening, what debugging you have done, etc

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