Cannot access editformitem in any row other than first

4 posts, 0 answers
  1. Marius
    Marius avatar
    10 posts
    Member since:
    Aug 2012

    Posted 17 Jun 2014 Link to this post

    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

     }

    }
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 17 Jun 2014 in reply to Marius Link to this post

    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
  3. Marius
    Marius avatar
    10 posts
    Member since:
    Aug 2012

    Posted 19 Jun 2014 Link to this post



    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
  4. Marius
    Marius avatar
    10 posts
    Member since:
    Aug 2012

    Posted 19 Jun 2014 in reply to Marius Link to this post

    Finally found the problem :
    get_editFormItem() only works for EDITForms and Popup...not inPlace editing...I changed it to get_element() and it WORKED!!!!
Back to Top