文章分類/

Infragistics|Ultimate UI Jquery|希望能以讀取專用的column去對igGrid新的「行」動態設定初始值

尚無瀏覽量
2023-04-14 更新

infragistics log

如果您想以讀取專用的column去對igGrid新的「行」動態設定初始值,請按照下列步驟設定:

  • 對於相關的「列」中使用的編輯器。
  •         將「readOnly」設置為true。
  •         設置disabled為true(※可選)。
  • 在igGridUpdating的editRowStarted事件中為相關列的編輯器設定初始值。
$("#grid1").igGrid({
    // ... (省略) ...
    columns: [
        { headerText: "ID", key: "ID", dataType: "number", width: "150px" },
        { headerText: "Name", key: "Name", dataType: "string", width: "250px" },
        { headerText: "", key: "CreatedOn", dataType: "date", format: "yyyy/MM/dd HH:mm:ss", width: "250px" },
    ],
    features: [
        {
            name: "Updating",
            editMode: "row",
            // ... (省略) ...
            columnSettings: [
                {
                    columnKey: "CreatedOn",

                    // 對於您在列中使用的編輯器
                    editorOptions: {
                        // 設定readOnly為true。
                        readOnly: true,
                        // 設定disabled為true(※任意)。
                        disabled: true,
                    },
                },
            ],

            // editRowStarted 為事件新增事件處理程序。
            editRowStarted: function(evt, ui){
                // 對於新增的行
                if(ui.rowAdding){
                    // 獲取「CreatedOn」列使用的編輯器。
                    var editorForCreatedOn = ui.owner.editorForKey("CreatedOn");
                    // 在編輯器中設置定初始值。
                    $(editorForCreatedOn).igDateEditor("value", new Date());
                }
            }
        }
    ]
});

執行結果

範例

KB2744_DefaultValueToReadOnlyColumn(Download)


API リファレンス

快速跳轉目錄

✦ 群昱 AccessSoft 你的全面軟體解決方案 ✦

身為全球眾多知名軟體在台灣合作夥伴,歡迎諮詢你需要的軟體服務!

Picture of 軟體專家
軟體專家

群昱作為全球知名軟體推薦合作夥伴,致力於提供更多軟體解決方案給你!

更多軟體新知

立即詢價

請留下完整資訊,以便我們提供精確的服務內容給你。

詢價資訊