Hello,
I have a radgrid which is binding on the basis of drop down selection. This Radgrid is inside update panel. I am selecting its row using javascript. On radiobutton SelectedIndexChangedevent this script is calling.
<script type=
"text/javascript"
>
function
SelectMeOnly(objRadioButton, grdName)
{
var
i, obj;
for
(i=0; i<document.all.length; i++)
{
obj = document.all(i);
if
(obj.type ==
"radio"
)
{
if
(objRadioButton.substr(0, grdName.length) == grdName)
if
(objRadioButton == obj.id)
obj.checked =
false
;
}
}
document.getElementById(objRadioButton).checked =
true
;
}
</script>
I am using RegisterStartup script placed in my Page_Load to run script on partial post back due to update panel:
protected
void
Page_Load(
object
sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(UpdatePanel8,
this
.GetType(),
"SelectMeOnly"
,
"SelectMeOnly();"
,
true
);
}
Following is my grid html:
<
div
class
=
"dashboarddiv"
id
=
"dragdiv"
style
=
"width:800px;"
>
<
asp:UpdatePanel
ID
=
"UpdatePanel8"
runat
=
"server"
>
<
telerik:RadGrid
ID
=
"gv_BO"
runat
=
"server"
ShowHeaderWhenEmpty
=
"true"
EmptyDataText
=
"No records to display"
AutoGenerateColumns
=
"False"
RenderMode
=
"Lightweight"
CellPadding
=
"0"
ForeColor
=
"#333333"
GridLines
=
"None"
MasterTableView-EditFormSettings-EditColumn-
AutoPostBackOnFilter
=
"false"
AllowSorting
=
"True"
Skin
=
"Telerik"
OnNeedDataSource
=
"grd_BO_NeedDataSource"
OnItemDataBound
=
"gv_BO_ItemDataBound"
Height
=
"194px"
Width
=
"750px"
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
SaveScrollPosition
=
"true"
>
</
Scrolling
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
ClientDataKeyNames
=
"lblRowNumber,CA_ACC_CODE,CA_TITLE,CC_COSTCNTR_CODE,CC_DESC,CP_EXCH_RATEREP1,BGT_ACTUAL_AMT,BGT_ANALYSIS1,BGT_ANALYSIS3"
DataKeyNames
=
"lblRowNumber"
Width
=
"100px"
TableLayout
=
"Fixed"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
/>
<
Columns
>
<
telerik:GridTemplateColumn
DataField
=
"lblRowNumber"
HeaderText
=
"S.No."
HeaderStyle-Width
=
"40px"
ItemStyle-BorderColor
=
"#d6d6d6"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblRowNumber"
runat
=
"server"
style
=
"text-align:center"
Width
=
"40px"
Text='<%# Bind("lblRowNumber")%>' />
</
ItemTemplate
>
<
HeaderStyle
Width
=
"40px"
/>
<
ItemStyle
BorderColor
=
"#D6D6D6"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"rdSelect"
HeaderStyle-HorizontalAlign
=
"Center"
ItemStyle-HorizontalAlign
=
"Center"
HeaderText
=
"Select"
HeaderStyle-Width
=
"80px"
>
<
ItemTemplate
>
<
asp:RadioButton
ID
=
"rdSelect"
runat
=
"server"
Width
=
"60px"
AutoPostBack
=
"True"
OnCheckedChanged
=
"rdSelect_CheckedChanged"
/>
</
ItemTemplate
>
<
HeaderStyle
HorizontalAlign
=
"Center"
Width
=
"80px"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridTemplateColumn
>
But unfortunately the alignment of my grid (scrolling, height) is behaving abnormally on each post back or even page load. On first load the grid is going out of div. On post back it is missing its scrollbar. I did try so many solutions like static header = "false" EnableViewState="true" but nothing is working. Please help me.
Note: If I remove RegisterStartupScript from page_load my radgrid behaves absolutely fine except that my row is not selecting. After adding RegisterStartupScript line my radgrid started behaving like this.