使用javascript过滤值

时间:2015-04-10 14:20:05

标签: javascript jquery

在下面的代码中,我使用AJAX获取返回值,现在我想过滤这些值。我的返回值如下所示:

"ProductID":1 ,
"ProductName": Salt

我只想要ProductName。请帮我这样做。

function LoadProducts() {
    var LocationID = $('#<%= ddlLocations.ClientID %>').val();
    var ProductTypeID = $('#<%= ddlProductTypes.ClientID %>').val();

    $("#product").dataTable({
        "oLanguage": {
            "sZeroRecords": "No records to display",
            "sSearch": "Search"
        },
        "aLengthMenu": [[10, 25, 50, 100, 150, 250, 500, -1], [10, 25, 50, 100, 150, 250, 500, "All"]],
        "iDisplayLength": 10,
        "bSortClasses": false,
        "bStateSave": false,
        "bPaginate": true,
        "bAutoWidth": false,
        "bProcessing": true,
        "bServerSide": false,
        "bDestroy": true,
        "sAjaxSource": "ProductsNew.aspx/GetProducts",
        "bJQueryUI": true,
        "sPaginationType": "simple",
        "bDeferRender": true,
        "fnServerData": function (sSource, aoData, fnCallback) {
            $.ajax({
                "dataType": 'json',
                "contentType": "application/json; charset=utf-8",
                "type": "POST",
                "url": sSource,
                "data": "{'vLocationID': '" + LocationID + "','vProductTypeID': '" + ProductTypeID + "'}",
                "success":
                                function (msg) {
                                    var json = jQuery.parseJSON(msg.d);

                                    window.localStorage.setItem("Productlist", msg.d);
                                    fnCallback(json);
                                    $("#product").show();
                                }
            });


        },
        "aoColumns": [
                { "mDataProp": "Location", "sWidth": "125px" },
                { "mDataProp": "ProductCode", "sWidth": "100px" },
                { "mDataProp": "ProductName", "sWidth": "125px" },
                { "mDataProp": "ProductTypeName", "sWidth": "125px" },
                { "mDataProp": "CurrentStock", "sWidth": "50px" },
                { "mDataProp": "UnitType", "sWidth": "50px" },
                { "mDataProp": "ProductID" },
                { "mDataProp": "LocationID" },
                {
                    "mDataProp": "ProductID", "bSearchable": false, "bSortable": false, "sWidth": "40px",

                    "mRender": function (data, type, full) {

                        var str = '<button type="button" id="btnEdit" onclick="openMyModal(\'ProductDetails.aspx?ProductID=' + full.ProductID + '&LocID=' + full.LocationID + '\')">Edit</button>';
                        return str;
                    }
                }
            ],
        "columnDefs": [
                {
                    "visible": false, "targets": 6
                },
                {
                    "visible": false, "targets": 7
                },
                {
                    "sClass": "relative-postition-and-break-word"
                }
            ]

    });                     
    }

0 个答案:

没有答案