0

ポップアップ ボタンを非表示にするために、ポップアップ ボタンの [OK] ボタンを 2 回押す必要がある理由を見つけようとしているところに問題があります。私のコードから、アラート ステートメントが 1 つしかないのに、誤って 2 つのアラート ステートメントを呼び出したかのように動作することがわかります。

function intialiseKendoGrid(date) {
     gridResult = $('#grid').kendoGrid({
         scrollable: {
             virtual: true
         },
         navigatable: true,
         groupable: true,
         sortable: true,
         selectable: "row",
         pageable: true,

         pageable: {
             input: true,
             numeric: false
         },

         resizable: true,
         reorderable: true,
         filterable: {
             extra: false
         },
         columns: [{
             field: "DealNumber",
             width: 150,
             title: "DealNumber",

             filterable: {
                 operators: {
                     string: {
                         startswith: "Starts With",
                         contains: "Contains"
                     }
                 }

             },
         },
         {
             field: "DealIssuer",
             width: 150,
             title: "Issuer",
             filterable: {
                 operators: {
                     string: {
                         startswith: "Starts With",
                         contains: "Contains"
                     }
                 }
             },
             //template: "<a href='http://manager.dealogic.com/ManagerV3/CPCortex/Default/${DealNumber}'>${DealNumber}</a>"  
             template: "<a>${DealIssuer}</a>"

         }, {
             field: "Ticker",
             width: 150,
             title: "Ticker",
             filterable: {
                 operators: {
                     string: {
                         startswith: "Starts With",
                         contains: "Contains"
                     }
                 }
             }    
         }, {
             field: "DealExchange",
             width: 150,
             title: "Exchange",
             filterable: {
                 operators: {

                     string: {
                         startswith: "Starts With",
                         contains: "Contains"
                     }
                 }
             }
         }, {
             field: "DealType",
             width: 150,
             title: "Type",
             filterable: {
                 operators: {
                     string: {
                         startswith: "Starts With",
                         contains: "Contains"
                     }
                 }
             }

         }, {
             field: "DealValue",
             width: 150,
             title: "Value ($m)",
             filterable: {
                 operators: {
                     string: {
                         startswith: "Starts With",
                         contains: "Contains"
                     }
                 }
             },
             /*   template: '#= kendo.culture("en-US");kendo.toString(${DealValue/1000000},"p")#' */

             template: '#= kendo.toString(DealValue,"c2") #'

         }, {
             field: "DealStatus",
             width: 150,
             title: "Status",
             filterable: {
                 operators: {
                     string: {
                         startswith: "Starts With",
                         contains: "Contains"
                     }
                 }
             }

         }, {
             field: "DealPricingCompletionDate",
             width: 230,
             title: "DealPricingCompletionDate",
             format: "{0:dd/MM/yyyy}",
             filterable: {
                 ui: "datetimepicker",
                 operators: {
                     date: {
                         gt: "After",
                         lt: "Before",
                         eq: "Equals"
                     },
                     messages: {
                         filter: "Apply",
                         clear: "Clear"
                     }
                 }

             }
         },   
         ],

         change: function () {
             var text = "";
             var grid = this;
             grid.select().each(function () {
                 var dataItem = grid.dataItem($(this));
                 text += "DealNumber: " + dataItem.DealNumber + "\n" + "Issuer: " + dataItem.DealIssuer + "\n" + "Ticker: " + dataItem.Ticker + "\n" + "Type: " + dataItem.DealType + "\n" + "Value: " + dataItem.DealValue + "\n" +
                     "Status " + dataItem.DealStatus + "\n" + "DealPricingCompletionDate: " + kendo.toString(dataItem.DealPricingCompletionDate, "dd/MM/yyyy");
             });
             alert(text);
         },
         height: 700
     }).data("kendoGrid");
4

2 に答える 2

3

change イベントが 2 回トリガーalert()されており、 が change イベントにバインドされているため、これも 2 回ポップアップします。

変更イベントのドキュメントをご覧ください。「ユーザーがグリッド内のテーブル行またはセルを選択したときに発生します。」

おそらく、1 つは行用、もう 1 つはセル用の 2 回発生していますか? 私はあなたが持っているselectable: "row"ように見えますが、行に対してのみ発砲する必要があります。

変更イベントを更新してchange: function (e) { console.log(e); }、デバッグ コンソールで出力を確認します。これにより、トリガーされている要素に関するヒントが得られます。

次に、変更イベントに追加e.preventDefault();して、他のイベントがトリガーされないようにすることができます。

于 2013-04-18T15:31:01.570 に答える
1

長い遅れの後、現在クラックされています。私がしなければならなかったのは、タイムアウトで SetTimeOut メソッドを使用することだけでした。0 は、時間パラメーターを指定しないことを意味します。したがって、固定コードは

    function onRowSelected(e) {
        e.preventDefault();
        console.log(e.sender);
        var text = "";
        var grid = this;
        grid.select().each(function () {
            var dataItem = grid.dataItem($(this));
            text += "DealNumber: " + dataItem.DealNumber + "\n" + "Issuer: " +
                dataItem.DealIssuer + "\n" + "Ticker: " + dataItem.Ticker + "\n" + "Type: " + dataItem.DealType + "\n" + "Value: " + dataItem.DealValue + "\n" +
                "Status " + dataItem.DealStatus + "\n" + "DealPricingCompletionDate: " + kendo.toString(dataItem.DealPricingCompletionDate, "dd/MM/yyyy");
        });
        setTimeout(function () { alert(text) },0);

    }
于 2013-04-23T08:11:39.513 に答える