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
ItemCreated
AjaxRequest
Script
Thnx in advance
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