2016-08-11 26 views
0

我需要一個kendo網格內的內聯textarea來允許用戶編輯一個字符串值。我想使用textarea,因爲這個值可能很長。我使用的是自定義編輯器來實現這個喜歡這裏提到的:http://www.telerik.com/forums/how-to-change-input-to-textarea-in-popup-editor在劍道網格中設置textarea的大小

我設置textarea的寬度和高度是一樣這似乎並不容器的

$('<textarea data-text-field="Label" data-value-field="Value" data-bind="value:' + options.field + '" style="width: ' + container.width() + 'px;height:' + container.height() + 'px" />') 

工作。當我點擊要編輯的單元格之前,在我的開發人員工具中檢查textarea元素的高度時,它顯示爲35px,之後顯示爲47px。這會導致網格的其餘部分向下移動。

http://dojo.telerik.com/@unicorn2/eCAkU

回答

1

那是因爲你不能只使用container的高度內本身元素的高度,在這種情況下。例如,該行具有其他間距屬性,例如填充。在一個簡單而快速的拍攝中,我通過了這個:

$('<textarea data-text-field="Label" data-value-field="Value" data-bind="value:' + options.field + '" style="width: ' + (container.width() - 10) + 'px;height:' + (container.height() - 12) + 'px" />').appendTo(container); 

Demo

只是減少一點容器的尺寸,它適合行高非常好。唯一的問題是斷線,因爲當調用editor回調函數時,容器的內容被重置,行的高度變得像是單行一樣。然後container.height()返回單行高度。