0

私はjqxgridを使用しており、以下のコードスニペットがあり、Ajaxメソッドを呼び出すボタンクリックでロードインジケーターを表示し、成功メソッドで非表示にするか、リクエストが行われた時間からロードインジケーターを表示する必要があるため、表示したいデータが届くまで

      $("#btnSearch").bind('click', function () {

     //show indicator here
     LoadLookUpSearchGrid();
    }


    //Ajax call to fetch data
    function LoadLookUpSearchGrid() {
                 var filterRows = getGridRows();
                 $.ajax({
                 type: 'POST',
                 dataType: 'json',
                 async: false,
                 cache: false,
                 url: 'AddEditView.aspx/LoadLookUpSearchGrid',
                 data: JSON.stringify({ FilterType: $('select#ddlFilterType').val() , Id: $("#txtId").val() , Name: $("#txtName").val(), SearchText: '', FilterRows: filterGridRows}),
                 contentType: 'application/json; charset=utf-8',
                 success: function (data) {

                    var source = data.d;
               SetSearchFields($('select#ddlFilterType option:selected').text(), source);

                 },
                 error: function (err) {
                     alert(err.text + " : " + err.status);
                 }
                 });
             };

// データをフォーマットするソース オブジェクト function SetSearchFields(fieldName, source) {

                  var columns;

                 if (fieldName == "Operating Company") {

                          source =
                            {
                                datatype: "xml",
                                datafields: [
                                    { name: 'COMPANY', type: 'string' },
                                    { name: 'DESCR', type: 'string' }
                                    ],
                                async: false,
                                root: "Company",
                                localdata: source
                            };
                     columns = [
                           { text: 'OPCO ID', dataField: 'COMPANY', width: '30%' },
                           { text: 'Company Name', dataField: 'DESCR', width: '65%' }
                               ];

                 }

     lookupSearchResultGrid(source, columns,fieldName);
    }

//adaptor to fill source and bind grid
    function lookupSearchResultGrid(source, columns,fieldName) {

                 var searchViewGridDataAdapter = new $.jqx.dataAdapter(source);

                 $("#divLookupSearch").jqxGrid(
                        {
                            width: '100%',
                            source: searchViewGridDataAdapter,
                        theme: theme,
                        sortable: true,
                        pageable: true,
                        autoheight: true,
                        selectionmode: 'checkbox',
                        columns: columns
                    });
//hide indicator here on on success method of ajax call

         };
4

1 に答える 1

0

ボタンのクリックで showloadelement を呼び出し、Ajax 呼び出し成功のコールバック関数で hideloadelement を呼び出します。

     $("#btnSearch").bind('click', function () {
        $('#divLookupSearch').jqxGrid('showloadelement');
        //show indicator here
        LoadLookUpSearchGrid();
        }
       ...
        success: function (data) {
            $('#jqxGrid').jqxGrid('hideloadelement');
            var source = data.d;
            SetSearchFields($('select#ddlFilterType option:selected').text(), source);

        },
       ...

よろしくお願いします、

アルペッシュ

于 2014-03-01T05:31:23.883 に答える