[Kendo] 前端傳遞e 參數

前端真的是夠菜

有一次在接Kendo Grid DataSource時

                    //子檔
                    let detailInit2 = function (e): void {
                        feeId = e.data["FeeID"];
                        bdgItemSeqNo = e.data["BdgItemSeqNo"];
                        $("<div/>").appendTo(e.detailCell).kendoGrid({
                            name: "bdgListDetail",
                            dataSource: detailDataSource, //這裡
                            scrollable: false,
                            sortable: true,

想要把參數傳進去detailDataSource 裡面

 const detailDataSource = new kendo.data.DataSource({
                transport: {
                    read: (options) => {
                        //#region 發送請求
                        $.ajax({
                            url: Router.GetPath('GetBdgItemListData', 'Test'),
                            type: 'POST',
                            headers: self.headers,
                            data: {
                                chkList: chkList,
                                feeId: feeId,
                                bdgItemSeqNo: bdgItemSeqNo
                            },
                            success(result) {
                                if (!result.IsSuccess) {
                                    return;
                                }
                                console.log("子檔");
                                console.log(result.Grid);
                                options.success(result.Grid);
                            },
                            error() {
                                Message.AlertMessage("查詢異常。");
                            }
                        });

                        //#endregion
                    },
                    parameterMap() { }
                },

但Kendo Grid DataSource 只接受 Kendo.data.DataSource 物件

那我該如何改寫?

其實就是再用function(e) 把 程式包起來

return Kendo.data.DataSource 就好

                    //子檔
                    let detailInit2 = function (e): void {
                        feeId = e.data["FeeID"];
                        bdgItemSeqNo = e.data["BdgItemSeqNo"];
                        $("<div/>").appendTo(e.detailCell).kendoGrid({
                            name: "bdgListDetail",
                            dataSource: detailDataSource(e),//這裡
                            scrollable: false,
 const detailDataSource = function (e) {
            return new kendo.data.DataSource({
                transport: {
                    read: (options) => {
                        //#region 發送請求
                        $.ajax({
                            url: Router.GetPath('GetBdgItemListData', 'Test'),
                            type: 'POST',
                            headers: self.headers,
                            data: {
                                chkList: chkList,
                                feeId: feeId,
                                bdgItemSeqNo: bdgItemSeqNo
                            },
                            success(result) {
                                if (!result.IsSuccess) {
                                    return;
                                }
                                console.log("子檔");
                                console.log(result.Grid);
                                options.success(result.Grid);
                            },
                            error() {
                                Message.AlertMessage("查詢異常。");
                            }
                        });

                        //#endregion
                    },
                    parameterMap() { }
                },