简体   繁体   English

如何在RadGrid中为js的列分配一个值

[英]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: 我的方法有两个最明显的问题:

  1. I change only selected item, not all. 我只更改选定的项目,而不是全部。 When i try to use masterTableView.get_editItems() IE says that there is no such method. 当我尝试使用masterTableView.get_editItems()时,IE表示没有这种方法。
  2. This code produce stack overflow since function occurs on propertychange, and inside of it i change property. 由于函数发生在propertychange上,因此此代码产生堆栈溢出,并且在其中更改属性。

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.

相关问题 如何为Three.js中的属性分配常量值 - How can I assign a constant value to attributes in Three.js 如何使用 JS 为基于键的输入赋值? - How can I use JS to assign a value on an input based on a key? 我无法访问javascript中的radgrid列…如何访问此列? - i am unable to access radgrid column in javascript…how i can access this..? 如何仅更改包含对象的 React useState 中的一个值并将其他值分配给其他值? - How can I change only one value in a React useState that contains an object and assign a different one to the rest? 如何将特定功能分配给一个 JS 文件中的不同 HTML 页面? - How can I assign a specific function to different HTML pages in one JS file? 如何将刻度分配为与 D3.js 中轴所基于的相同 object 的不同键值相等? - How do I assign ticks to be equal to a different key value from the same object from the one on which the axis is based on in D3.js? 如何使用 angularjs 替换列表对象中的一个值并将相同的新值分配给相同的对象列表? - how can i replace one value from list object and same new value assign to same object list using angularjs? js将一个图像输入值分配给另一个 - js assign one image input value to another 如何分配一个变量的值的变量? - How do I assign a variable of one's variable's value? 如何在JS中为变量分配锚标记的名称? - How can i assign the name of an anchor tag to a variable in JS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM