Scenario: A RadGrid is populated on the client side using JavaScript calls to Web services after the page finishes loading. The grid starts out empty on the server side. The only notable problem I see is that table cell styles are not applied to new rows after increasing the page size in the NextPrevNumericAndAdvanced pager. An example table cell style is cell alignment. The original rows might have cells with align="right" attributes, but all the new rows that get added after increasing the page size have plain td tags with no attributes, making the grid look unusual. My current fix is to hide that page size control, but I would like to get this working.
What seems to happen is that an empty grid is created with the proper td attributes, but the empty grid does have enough blank rows to match the new larger page size.
For example, start with a page size of 3, a blank 4 row grid is created then populated with data, with the last row being removed. I think the extra row is for the optional footer, which the grid does not have. Change the page size to 10. After the postback, a blank 4 row grid is created, then populated with 10 rows, which properly expands the visible rows to 10, but the last six rows lack formatting attributes.
I’m not sure the best way to handle this issue.
<
telerik:RadGrid
runat
=
"server"
ID
=
"radgrid"
...>
<
MasterTableView
TableLayout
=
"Fixed"
>
<
Columns
>...</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"true"
UseStaticHeaders
=
"true"
/>
<
ClientEvents
OnKeyPress
=
"keyPress"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
oldScrollTop = 0;
function keyPress(sender, args) {
var keyCode = args.get_keyCode();
switch (keyCode) {
//If Down Key
case 40:
//set the scrolling position in propor
var scrollArea = document.getElementById(sender.get_element().id + "_GridData");
//try to cancel the scrolling and it's not working
//sender.ClientSettings.AllowScroll = false;
//try to set the scroll-area top position as same as the top of the first row,
//but scrollArea.scrollTop always be assigned to 53
scrollArea.scrollTop = 0;
break;
}
}
protected
void
RadFileExplorer1_ExplorerPopulated(
object
sender, RadFileExplorerPopulatedEventArgs e)
{
//some code .. then a for loop then
e.List[i].Attributes.Add(
"myKey"
,
"myValue"
);
}
}
<
telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
CellSpacing="0" GridLines="None" Height="520px" OnNeedDataSource="RadGrid1_NeedDataSource"
OnUpdateCommand="RadGrid1_UpdateCommand" PageSize="20" Skin="WebBlue" Visible="False"
OnPreRender="RadGrid1_PreRender">
<ClientSettings>
<Selecting CellSelectionMode="None" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView DataKeyNames="ITEM_NUMBER" Width="100%">
<CommandItemSettings ExportToPdfText="Export to PDF" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True">
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
</ExpandCollapseColumn>
<Columns>
<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Edit" HeaderStyle-Width="4%"
HeaderText="Edit" Text="Edit" UniqueName="EditButton" Visible="true">
<HeaderStyle Width="4%" />
</telerik:GridButtonColumn>
<telerik:GridBoundColumn DataField="Total Items" FilterControlAltText="Filter Total_Items column"
HeaderStyle-Font-Bold="true" HeaderStyle-Width="6%" HeaderText="Mapped Items"
ReadOnly="true" SortExpression="Total_Items" UniqueName="Total_Items">
<HeaderStyle Font-Bold="True" Width="6%" />
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn EditFormHeaderTextFormat="<font color='red'>*</font>{0}"
HeaderStyle-Font-Bold="true" HeaderStyle-Width="6%" HeaderText="Ariba_Cat1" UniqueName="Ariba_Cat1">
<ItemTemplate>
<asp:Label ID="lbl_catone" runat="server" Text='<%#Eval("Ariba_Cat1") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="rcb_aribacatone" runat="server" DataSourceID="Ariba_Cat1"
DataTextField="ariba_cat1" DataValueField="ariba_cat1">
</telerik:RadComboBox>
</EditItemTemplate>
<HeaderStyle Font-Bold="True" />
<ItemStyle HorizontalAlign="Left" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn EditFormHeaderTextFormat="<font color='red'>*</font>{0}"
HeaderStyle-Font-Bold="true" HeaderStyle-Width="6%" HeaderText="Ariba_Cat2" UniqueName="Ariba_Cat2">
<ItemTemplate>
<asp:Label ID="lbl_cattwo" runat="server" Text='<%#Eval("Ariba_Cat2") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="rcb_aribacattwo" runat="server" DataSourceID="aribacat2"
DataTextField="ariba_cat2" DataValueField="ariba_cat2" >
</telerik:RadComboBox>
</EditItemTemplate>
<HeaderStyle Font-Bold="True" />
<ItemStyle HorizontalAlign="Left" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn EditFormHeaderTextFormat="<font color='red'>*</font>{0}"
HeaderStyle-Font-Bold="true" HeaderStyle-Width="6%" HeaderText="Ariba_Cat3" UniqueName="Ariba_Cat3">
<ItemTemplate>
<asp:Label ID="lbl_catthree" runat="server" Text='<%#Eval("Ariba_Cat3") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="rcb_aribacatthree" runat="server" DataSourceID="SubCategory"
DataTextField="ariba_cat3" DataValueField="ariba_cat3" >
</telerik:RadComboBox>
</EditItemTemplate>
<HeaderStyle Font-Bold="True" />
<ItemStyle HorizontalAlign="Left" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn EditFormHeaderTextFormat="<font color='red'>*</font>{0}"
HeaderStyle-Font-Bold="true" HeaderStyle-Width="6%" HeaderText="Ariba_Cat4" UniqueName="Ariba_Cat4">
<EditItemTemplate>
<telerik:RadComboBox ID="rcb_aribacatfour" runat="server" DataSourceID="ds_aribafour"
DataTextField="ariba_cat4" DataValueField="ariba_cat4" SelectedValue='<%# Bind("Ariba_Cat4") %>'>
</telerik:RadComboBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lbl_catfour" runat="server" Text='<%#Eval("Ariba_Cat4") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle Font-Bold="True" />
<ItemStyle HorizontalAlign="Left" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn EditFormHeaderTextFormat="<font color='red'>*</font>{0}"
HeaderStyle-Font-Bold="true" HeaderStyle-Width="6%" HeaderText="Ariba_Cat5" UniqueName="Ariba_Cat5">
<EditItemTemplate>
<telerik:RadComboBox ID="rcb_aribacatfive" runat="server" DataSourceID="ds_catfive"
DataTextField="ariba_cat5" DataValueField="ariba_cat5" SelectedValue='<%# Bind("Ariba_Cat5") %>'>
</telerik:RadComboBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lbl_catfive" runat="server" Text='<%#Eval("Ariba_Cat5") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle Font-Bold="True" />
<ItemStyle HorizontalAlign="Left" />
</telerik:GridTemplateColumn>
</Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
</telerik:RadGrid>
while clicking on edit button getting below error.
RadTab documentsRadTab = mainTmTabStrip.TabStrip.Tabs.FindTabByText(
"Documents"
);
documentsRadTab.Selected =
true
;
mainTmTabStrip.TabStrip.SelectedIndex = documentsRadTab.Index;
ResourceType rt = new ResourceType("UserCalender");
rt.ForeignKeyField = "UserTypeId";
rt.KeyField = "UserTypeId";
rt.TextField = "UserTypeName";
rt.DataSource = GetUserTypes();
RadScheduler1.ResourceTypes.Add(rt);