This is a migrated thread and some comments may be shown as answers.

Cannot access editformitem in any row other than first

3 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marius
Top achievements
Rank 1
Marius asked on 17 Jun 2014, 11:36 AM
function checkEnter() {
if (navigator.userAgent.indexOf('Firefox') !== -1 || navigator.userAgent.indexOf('Chrome') !== -1) {

if (event.keyCode === 13) {
var grid = $find("<%= rgClaimLines.ClientID %>");
if (grid) {
var EditItems = grid.get_editItems();
for (var i = 0; i < EditItems.length; i++) {
var editItem = EditItems[0];
var textBox = $(editItem.get_editFormItem()).find("input[id*='ddl_Paid']").get(0);
textBox.focus();
event.preventDefault();
return false;
}
}

The above function works perfectly on the first row of my grid, but fails on any subsequent rows....

Any ideas?

Regards
Marius

 }

}

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 17 Jun 2014, 05:55 PM
Hello,

Correct code:
var editItem = EditItems[i];

You have written "[0]" , So it will always return first row.

Let me know if any concern.

Thanks,
Jayesh Goyani
0
Marius
Top achievements
Rank 1
answered on 19 Jun 2014, 09:23 AM


the grid markup looks like this...
...
<telerik:GridTemplateColumn DataField="BenfcNum" FilterControlAltText="Filter BenfcNum column" HeaderStyle-Width="40" HeaderText="Patient Name" ItemStyle-Width="40" SortExpression="BenfcNum" UniqueName="BenfcNum" ForceExtractValue="Always" AutoPostBackOnFilter="True">
<EditItemTemplate>
<telerik:RadComboBox ID="ddl_Benfc" EmptyMessage="Select Patient..." DataValueField="BenfcNum" OnSelectedIndexChanged="ddl_Benfc_SelectedIndexChanged" OnClientSelectedIndexChanged="onClientSelectedIndexChanged" runat="server" Width="170" AppendDataBoundItems="True" Font-Size="XX-Small" Font-Names="Arial" AutoPostBack="False" DropDownWidth="250" onKeyDown="checkEnter1();" MarkFirstMatch="True" EnableTextSelection="False">
</telerik:RadComboBox>
</EditItemTemplate>
<ItemTemplate>
<telerik:RadComboBox ID="ddl_Benfc" EmptyMessage="Select Patient..." DataValueField="BenfcNum" runat="server" Width="170" Enabled="false" AppendDataBoundItems="True" Font-Size="XX-Small" DropDownWidth="250">
</telerik:RadComboBox>
</ItemTemplate>
<HeaderStyle Width="40px" />
<ItemStyle Width="40px" />
</telerik:GridTemplateColumn>
....
the problem is that this line :
var textBox = $(editItem.get_editFormItem()).find("input[id*='ddl_Benfc']").get(0);
actual returns an array of all ddl_Benfc instances and because the same name is used in both the item and edit templates it returns 2 for the first row, 4 for the second, 6 for the third etc. and iit seems that get(0) always gets a reference to the first instance. How do i get a referne to the current edit template instance?????


regards
Marius
0
Marius
Top achievements
Rank 1
answered on 19 Jun 2014, 09:52 AM
Finally found the problem :
get_editFormItem() only works for EDITForms and Popup...not inPlace editing...I changed it to get_element() and it WORKED!!!!
Tags
Grid
Asked by
Marius
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Marius
Top achievements
Rank 1
Share this question
or