jQWidgets Forums

jQuery UI Widgets Forums DataTable Datatable datasource on selection change

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 10 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • jineshsvccam
    Participant

    Hai friends i am new to this forum and webbased application.please help me to learn new things
    my requirement is to display data on table by the combobox selection
    i am using asp.net
    my problem is how to pass parameter to function “GetCustomersfn(string cusID)”

    this is the function i am using and it works fine.
    [WebMethod]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Xml)]
    public string GetCustomersfn(string cusID)
    {
    string query = “SELECT * FROM Customers WHERE CustomerID LIKE @CustomerID”;
    string tablename = “Customers”;
    SqlCommand cmd = new SqlCommand(query);
    cmd.Parameters.AddWithValue(“CustomerID”, “%” + cusID.Substring(0, 1) + “%”);
    DataSet data = GetData(cmd, tablename);
    //return GetData(cmd, tablename).GetXml();
    System.IO.StringWriter writer = new System.IO.StringWriter();
    data.Tables[0].WriteXml(writer, XmlWriteMode.WriteSchema, false);
    return writer.ToString();

    }

    script file is given below

    <script type=”text/javascript”>
    $(document).ready(function () {
    $(‘#dlcustomers’).change(function () {
    // var obj = {};
    // obj.cusID = $.trim($(“[id*=dlcustomers]”).val());
    // alert(obj.cusID);
    var cid = $.trim($(“[id*=dlcustomers]”).val());
    // alert(cid);

    source = {
    datatype: “xml”,
    datafields: [
    { name: ‘CompanyName’ },
    { name: ‘ContactName’ },
    { name: ‘ContactTitle’ },
    { name: ‘City’ },
    { name: ‘Country’ },
    { name: ‘Address’ }
    ],
    async: false,
    record: ‘Customers’,
    url: ‘DataWebService.asmx/GetCustomersfn’,
    data: { CusID: “A” }
    // data: JSON.stringify(obj),
    // formatdata: function (data) {
    // return { CusID: ‘a’ }
    // },

    };
    var dataAdapter = new $.jqx.dataAdapter(source,
    { contentType: ‘application/json; charset=utf-8’ }
    );
    $(“#dataTable”).jqxDataTable(
    {
    width: 850,
    height: 400,
    source: dataAdapter,
    pagerButtonsCount: 10,
    pageable: true,
    columnsresize: true,
    altRows: true,
    filterable: true,
    sortable: true,
    filtermode: ‘advanced’,
    // pagerMode: ‘advanced’,
    // groups: [‘City’],
    columns: [
    { text: ‘Company Name’, dataField: ‘CompanyName’, width: 250 },
    { text: ‘Contact Name’, dataField: ‘ContactName’, width: 150 },
    { text: ‘Contact Title’, dataField: ‘ContactTitle’, width: 180 },
    { text: ‘Address’, dataField: ‘Address’, width: 180 },
    { text: ‘City’, dataField: ‘City’, width: 80 },
    { text: ‘Country’, dataField: ‘Country’, width: 100 }
    ]
    });
    });
    });
    </script>

    please help…..


    Peter Stoev
    Keymaster

    Hi jineshsvccam,

    May be the data member’s syntax should be something like:

    data: “{‘featureClass’: ‘P’, ‘style’: ‘full’, ‘maxRows’: ’50’}”,

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.