[英]How can I assign one value to column by js in RadGrid
I have Radgrid with all rows always in edit mode. 我的Radgrid所有行始终处于编辑模式。 I want following functionality in one of the columns: after item is edited, all rows in this colum take this value.
我希望在其中一列中具有以下功能:编辑项目后,此列中的所有行均采用此值。 Here is how my column looks like.
这是我的专栏的样子。
<telerik:GridTemplateColumn HeaderText="Opis" HeaderStyle-Width="125px" ItemStyle-Width="120px"
UniqueName="poz_nazwa">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "poz_nazwa")%>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadTextBox runat="server" ID="Rtopis" DataTextField="poz_nazwa" DataValueField="poz_nazwa"
Width="120px" Text='<%#Bind("poz_nazwa") %>' onfocus="javascript:podp(this.id);"
AutoCompleteType="Disabled" onpropertychange="Opisblur()">
</telerik:RadTextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
And here is what i tried and is not working: 这是我尝试但不起作用的内容:
function OpisBlur() {
if (event.propertyName == 'value') {
var grid = $find("<%=RadGPozycje.ClientID %>");
var masterTableView = grid.get_masterTableView();
var iloop;
if (masterTableView != null) {
var gridItems = masterTableView.get_dataItems();
var i;
for (i = 0; i < gridItems.length; ++i) {
var gridItem = gridItems[1];
var cell = gridItem.get_cell("poz_nazwa");
var controlsArray = cell.getElementsByTagName('input');
if (controlsArray.length > 0) {
var rdo = controlsArray[0];
rdo.value = "valueofchangeditem";
}
}
}
}
}
There are two most obvious problems with my approach: 我的方法有两个最明显的问题:
Can you help me find solution to implement desired functionality? 您能帮我找到实现所需功能的解决方案吗?
In your ItemTemplate for the column, can you put a label or something that has a className? 在列的ItemTemplate中,可以放置标签或具有className的东西吗? Then wouldn't you be able to update everything on the page that has that class with the new value?
然后,您是否能够使用新值更新具有该类的页面上的所有内容?
$('.poz_nazwaClass').val("valueofchangeditem");
If you don't use jQuery, adding a tag then, element.getElementsByTagName('poz_nazwaTag') then loop through the elements I think. 如果您不使用jQuery,请添加一个标签,然后element.getElementsByTagName('poz_nazwaTag')遍历我认为的元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.