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

Error while setting cursor position

1 Answer 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Remya
Top achievements
Rank 1
Remya asked on 23 Mar 2012, 01:29 PM
Hi,

I am trying to set the position of Filter textbox in my grid by javascript. On first keypress in filter textbox everything works fine, but from second time onwards i am getting an error htmlfile: Could not complete the operation due to error 800a025e.

My Code is:
Grid
<telerik:RadGrid ID="RadGridSpeciality" runat="server" CellSpacing="0" GridLines="None"
    AllowFilteringByColumn="true" EnableLinqExpressions="true">
    <ClientSettings>
        <Selecting CellSelectionMode="None"></Selecting>
    </ClientSettings>
    <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top">
        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridBoundColumn FilterControlAltText="Filter SlNo column" HeaderText="Sl No"
                UniqueName="SlNo" DataField="SlNo">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn FilterControlAltText="Filter Code column" HeaderText="Code"
                UniqueName="Code" DataField="Code" AutoPostBackOnFilter="true">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn FilterControlAltText="Filter Name column" HeaderText="Name"
                UniqueName="Name" DataField="Name">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn FilterControlAltText="Filter No Of Doctor column" HeaderText="NoOfDoctor"
                UniqueName="NoOf" DataField="NoOfDoctor">
            </telerik:GridBoundColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
</telerik:RadGrid>

ItemCreated

Private Sub RadGridSpeciality_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGridSpeciality.ItemCreated
       If TypeOf e.Item Is GridFilteringItem Then
           Dim FilterItm As GridFilteringItem = TryCast(e.Item, GridFilteringItem)
           For Each column As GridColumn In RadGridSpeciality.Columns
               Dim filterBox As TextBox = TryCast(FilterItm(column.UniqueName).Controls(0), TextBox)
               filterBox.Attributes.Add("Onkeyup", "dofilter(this,event,1);")
               If hfUniqueName.Value <> "" Then
                   If hfUniqueName.Value = column.UniqueName Then
                       ScriptManager.RegisterStartupScript(Me, Me.GetType(), "starScript", "setCursorToEnd('" & filterBox.ClientID & "','" & hfValue.Value & "');", True)
                   End If
               End If
           Next
       End If
   End Sub

AjaxRequest

Private Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
        If e.Argument <> "" Then
            RadGridSpeciality.MasterTableView.FilterExpression = "(Code.Contains(""" & e.Argument & """))" '"([Code] <>'')"
            '"([Code] LIKE \'%" & e.Argument & "%'\)"
            hfValue.Value = e.Argument
            hfUniqueName.Value = "Code"
            RadGridSpeciality.Rebind()
            Return
        End If
    End Sub


Script

function dofilter(sender, eventArgs, index) {
                eventArgs.cancelBubble = true;
                eventArgs.returnValue = false;
                if (eventArgs.stopPropagation) {
                    eventArgs.stopPropagation();
                    eventArgs.preventDefault();
                }
                var masterTableView = $find("<%= RadGridSpeciality.ClientID %>").get_masterTableView();
                var columns = masterTableView.get_columns();
                uniqueName = columns[index].get_uniqueName();
                var filterval = sender.value;
                if (filterval != '') {
                    $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest(filterval);
                }
                return true;
            }

function setCursorToEnd(txtboxFilter, Val) {
                document.getElementById(txtboxFilter).value = Val;
                var txtFilter = document.getElementById(txtboxFilter);
                if (txtFilter != null && txtFilter.value.length > 0) {
                    if (txtFilter.createTextRange) {
                        var FieldRange = txtFilter.createTextRange();
                        FieldRange.moveStart('character', txtFilter.value.length);
                        FieldRange.collapse();
                        FieldRange.select(); //Error comes here
                    }
                }
            }


Thnx in advance

1 Answer, 1 is accepted

Sort by
0
BabaYa
Top achievements
Rank 1
answered on 28 Mar 2012, 07:59 AM
Hi

May be problem in ajax. Try execute your code without ajax. You can also see here:

http://www.telerik.com/community/forums/aspnet-ajax/general-discussions/could-not-complete-the-operation-input-problems-sample-included.aspx

Thenks
BabaYa
Tags
Grid
Asked by
Remya
Top achievements
Rank 1
Answers by
BabaYa
Top achievements
Rank 1
Share this question
or