Hi All
This is my scenario
I have a RadGrid, then I have an EditFormTemplate and inside I have a RadListBox, I'm able to select a value from codebehind, but I want to scroll the ListBox to the selected when the EditForm is showing, I followed this post but I'm not able to do it.
Here is my test code
ASP
Code Behind
Javascript
I know that I can only use the scrollIntoView() inside JavaScript but the function selectedIndexChanged is not firing, is there a way to scroll when I select the item in the code behind or server-side?
Thanks in advance
This is my scenario
I have a RadGrid, then I have an EditFormTemplate and inside I have a RadListBox, I'm able to select a value from codebehind, but I want to scroll the ListBox to the selected when the EditForm is showing, I followed this post but I'm not able to do it.
Here is my test code
ASP
<
telerik:RadGrid
ID
=
"Radgrid1"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
AutoGenerateColumns
=
"false"
AutoGenerateEditColumn
=
"true"
>
<
MasterTableView
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
PopUpSettings
Width
=
"620px"
Modal
=
"false"
Height
=
"550px"
/>
<
FormTemplate
>
<
telerik:RadListBox
ID
=
"RadListBox1"
runat
=
"server"
DataSource
=
"DS"
OnClientSelectedIndexChanged
=
"selectedIndexChanged"
>
</
telerik:RadListBox
>
</
FormTemplate
>
</
EditFormSettings
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"OrderID"
HeaderText
=
"OrderID"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Code Behind
Protected
Sub
RadGrid1_ItemDataBound(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridItemEventArgs)
Handles
RadGrid1.ItemDataBound
If
TypeOf
e.Item
Is
GridDataItem
Then
Dim
editItem
As
GridDataItem =
DirectCast
(e.Item, GridDataItem)
Dim
ddlCurrency
As
RadListBox =
DirectCast
(editItem.FindControl(
"RadListBox1"
), RadListBox)
If
ddlCurrency IsNot
Nothing
Then
Dim
item
As
RadListBoxItem = ddlCurrency.FindItemByText(strCurrency)
If
item IsNot
Nothing
Then
ddlCurrency.SelectedValue = hdnValue.Value
End
If
End
If
End
If
End
Sub
Javascript
function
selectedIndexChanged(sender, args)
{
var
item = args.get_item();
item.scrollIntoView();
}
I know that I can only use the scrollIntoView() inside JavaScript but the function selectedIndexChanged is not firing, is there a way to scroll when I select the item in the code behind or server-side?
Thanks in advance