簡體   English   中英

ShieldUI Grid - 僅在插入時顯示下拉列表

[英]ShieldUI Grid - show dropdown on insert only

我正在使用 ShieldUI 網格,並希望網格上的新行在其中一列中顯示下拉菜單。 此列不可編輯並顯示文本。 我希望用戶能夠從下拉列表中選擇一個值,但添加后不可編輯。 我已經多次查看文檔,但似乎無法弄清楚。

 $(document).ready(function() { $("#propertiesGrid").shieldGrid({ theme: "light-bootstrap", dataSource: { remote: { read: { url: "/api" + window.location.pathname + "/ProductAttributes", dataType: "json" } }, modify: { update: function(items, success, error) { $.ajax({ type: "PUT", url: "/api" + window.location.pathname + "/ProductAttributes", dataType: "json", contentType: "application/json", data: JSON.stringify(items[0].data) }).then(success, error); } } }, schema: { fields: { "attributeId": { path: "attributeId" }, "productAttributeId": { path: "productAttributeId" }, "productId": { path: "productId" }, "attributeName": { path: "attributeName" }, "minimum": { path: "minimum" }, "target": { path: "target" }, "maximum": { path: "maximum" }, "method": { path: "method" } } }, rowHover: false, resizing: true, scrolling: true, events: { insert: function() { AddNewRow() } }, editing: { enabled: true, type: "row", insertNewRowAt: "pagebottom" }, toolbar: [ { buttons: [ { commandName: "insert", caption: "Add Product" } ], position: "bottom" } ], paging: { pageSize: 10, pageLinksCount: 12, messages: { infoBarTemplate: "From {0} to {1} items of a total of {2}", firstTooltip: "First page", previousTooltip: "Previous page", nextTooltip: "Next page", lastTooltip: "Last page" } }, columns: [ { field: "attributeName", title: "Attribute", editable: false, id: "attributeName" }, { field: "minimum", title: "Minimum" }, { field: "target", title: "Target" }, { field: "maximum", title: "Maximum" }, { field: "method", title: "Method" }, { width: 150, title: " ", buttons: [ { commandName: "edit", caption: "Edit" }, { commandName: "delete", caption: "Delete" } ] } ] }); });

有一個解決方法。 讓您的列可編輯,只需綁定從網格拋出的編輯事件,找到該列的編輯器並隱藏它或將其替換為單元格的值。

events: {
    edit: function(e) {
        var target = $("#column_editor_id");
        target.hide();
    }    
},

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM