jQWidgets Forums

Forum Replies Created

Viewing 2 posts - 16 through 17 (of 17 total)
  • Author
    Posts

  • mullai.b
    Participant

    Hi Stephan,

    I eradicated the issue. i forget to include the script file

    Its working now its searching the content that exists in column first name, second name, product.

    How can search for column quantity, unit price.

    Thanks for your code.


    mullai.b
    Participant

    Hi Stephan,

    Thanks for the code.
    i tried with above code. But i am getting error message for object required when reaches a line code filtergroup = new $.jqx.filter();

    This demo illustrates the basic functionality of the Grid plugin. The jQWidgets Grid plugin offers rich support for interacting with data, including paging, grouping and sorting.

    $(document).ready(function () {
    var theme = “base”;

    $(‘#inputsearch’).keyup(function (e) {

    if (e.keyCode == 13) {
    var searchText = $(“#inputsearch”).val();
    setGlobalFilter(searchText)
    }

    if ($(‘#inputsearch’).val() == ”) {
    $(“#jqxgrid”).jqxGrid(‘clearfilters’);

    }
    });

    function setGlobalFilter(filtervalue) {

    alert(“Your Search Value: ” + filtervalue);
    var columns = $(“#jqxgrid”).jqxGrid(‘columns’);
    alert(columns.records.length);

    var filtergroup, filter;

    // the filtervalue must be aplied to all columns individually,
    //the column filters are combined using “OR” operator
    for (var i = 0; i < columns.records.length; i++) {
    if (!columns.records[i].hidden && columns.records[i].filterable) {

    alert(columns.records[i].datafield);
    filtergroup = new $.jqx.filter();
    // filtergroup.operator = 'or';
    // filter = filtergroup.createfilter('stringfilter', filtervalue, 'contains');
    // filtergroup.addfilter(1, filter);
    // $("#jqxgrid").jqxGrid('addfilter', columns.records[i].datafield, filtergroup);
    }
    }
    // $("#jqxgrid").jqxGrid('applyfilters');
    }

    // prepare the data
    var data = new Array();
    var firstNames =
    [
    "Andrew", "Nancy", "Shelley", "Regina", "Yoshi", "Antoni", "Mayumi", "Ian", "Peter", "Lars", "Petra", "Martin", "Sven", "Elio", "Beate", "Cheryl", "Michael", "Guylene"
    ];
    var lastNames =
    [
    "Fuller", "Davolio", "Burke", "Murphy", "Nagase", "Saavedra", "Ohno", "Devling", "Wilson", "Peterson", "Winkler", "Bein", "Petersen", "Rossi", "Vileid", "Saylor", "Bjorn", "Nodier"
    ];
    var productNames =
    [
    "Black Tea", "Green Tea", "Caffe Espresso", "Doubleshot Espresso", "Caffe Latte", "White Chocolate Mocha", "Cramel Latte", "Caffe Americano", "Cappuccino", "Espresso Truffle", "Espresso con Panna", "Peppermint Mocha Twist"
    ];
    var priceValues =
    [
    "2.25", "1.5", "3.0", "3.3", "4.5", "3.6", "3.8", "2.5", "5.0", "1.75", "3.25", "4.0"
    ];
    for (var i = 0; i < 200; i++) {
    var row = {};
    var productindex = Math.floor(Math.random() * productNames.length);
    var price = parseFloat(priceValues[productindex]);
    var quantity = 1 + Math.round(Math.random() * 10);
    row["firstname"] = firstNames[Math.floor(Math.random() * firstNames.length)];
    row["lastname"] = lastNames[Math.floor(Math.random() * lastNames.length)];
    row["productname"] = productNames[productindex];
    row["price"] = price;
    row["quantity"] = quantity;
    row["total"] = price * quantity;
    data[i] = row;
    }
    var source =
    {
    localdata: data,
    datatype: "array"
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    $("#jqxgrid").jqxGrid(
    {
    width: "100%",
    width: "90%",
    source: dataAdapter,
    theme: theme,
    columnsresize: true,
    columns: [
    { text: 'First Name', dataField: 'firstName', dataField: 'firstname', width: '10%' },
    { text: 'Last Name', dataField: 'lastname', width: '20%' },
    { text: 'Product', dataField: 'productname', width: '20%' },
    { text: 'Quantity', dataField: 'quantity', width: '10%', cellsalign: 'right' },
    { text: 'Unit Price', dataField: 'price', width: '20%', cellsalign: 'right', cellsformat: 'c2' },
    { text: 'Total', dataField: 'total', cellsalign: 'right', width: '20%', cellsformat: 'c2' }
    ]
    });
    // alert($("#jqxgrid").jqxGrid('columns').records.length);
    });

Viewing 2 posts - 16 through 17 (of 17 total)