简体   繁体   English

ShieldUI Grid - 仅在插入时显示下拉列表

[英]ShieldUI Grid - show dropdown on insert only

I'm using the ShieldUI Grid, and would like to have a new row on the grid show a dropdown in one of the columns.我正在使用 ShieldUI 网格,并希望网格上的新行在其中一列中显示下拉菜单。 This column is not editable and displays text.此列不可编辑并显示文本。 I want the user to be able to select a value from a dropdown, but it not be editable after being added.我希望用户能够从下拉列表中选择一个值,但添加后不可编辑。 I've reviewed the documentation multiple times, and can't seem to figure it out.我已经多次查看文档,但似乎无法弄清楚。

 $(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" } ] } ] }); });

There is a workaround.有一个解决方法。 Leave your column editable, just bind on the edit event thrown from the grid, find the editor for that column and just hide it or replace it with the value of the cell.让您的列可编辑,只需绑定从网格抛出的编辑事件,找到该列的编辑器并隐藏它或将其替换为单元格的值。

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