Most features work fine but I have some problems with RadGrid for Ajax.
1. When the page displays intially, the slider does not display. (Even if I set AlwaysVisible="true") However if the user clicks on a row in the grid thenthe slider displays. ASPX is below.
How can we display the slider when the page displays?
2. Do you have an example of a paging "Slider" that has the text horizontally aligned (side by side) with the slider graphic?
e.g. the words "Page: 1 out of 6667 pages" would appear to the right of the slider graphic.
3. Is there a special way to set font-size for data in the grid? I set it to "smaller" but it stays big.
4. Is there an example or guidance on how to do the following. Suppose we need a grid to edit employee records.
Each employee is in one company and each employee can be in zero or more departments inside the company.
So if we edit or add a new employee the user must select a company (e.g. from a dropdown list of all companies) and AFTER selecting a company the user may select zero or more departments (e.g. from a listbox).
So a normal edit feature is not sufficient. The contents of the list of departments depends on the company selected.
I can think of two general ideas. 4.1) If the inline edit form could have an event associated with user selection of a company from ddlistCompany. This event would cause data to be loaded into the listbox for Department that is on the edit form.
4.2) Another idea is not as nice for the user but could work. We could have a second edit button on the grid for "Edit Department". When the user clicks this button some kind of popup window is displayed that contains a listbox of Departments that are associated with the company in the row containing the edit button the user clicked on.
I found one way to do this. Have 2 edit form user controls, one for company data and one for department. You can use CommandArgument in these controls so you can identify them on the page or user control that uses them. For example the following. If CommandArgument == "S") I know which edit form user control should be the "active" one. The grid will have one edit button associated with each of thes 2 edit form user controls,
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == "RebindGrid")
{
PopulateOnPrerender =
false;
SetLabels();
RadGrid1.DataBind();
}
if (e.CommandName == "InitInsert")
{
if (((LinkButton)e.CommandSource).CommandArgument == "S")
{
RadGrid1.MasterTableView.EditFormSettings.UserControlName =
"~/Controls/UsersControlEditSCS.ascx";
}
else
{
RadGrid1.MasterTableView.EditFormSettings.UserControlName =
"~/Controls/UsersControlEdit.ascx";
}
}
}
John (Steve)
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UsersControl.ascx.cs"
Inherits="BalancedFlow.WebSite3._5.Controls.UsersControl" %>
<%@ Register TagPrefix="rad" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<style type="text/css">
#Table5
{
width: 1016px;
}
.style9
{
width: 91%;
margin-right: 24px;
height: 25px;
}
.style13
{
width: 260px;
}
</style>
<table cellspacing="0" cellpadding="0" width="133" border="0">
<tr valign="top">
<td width="133" height="988">
<table cellspacing="0" cellpadding="0" width="976" border="0">
<tr valign="top">
<td colspan="2" height="50">
<table id="Table5" cellspacing="1" cellpadding="1" border="0">
<tr>
<td height="45">
<asp:Panel ID="pnlTop" runat="server" Height="36px" Width="833px">
<table class="style9">
<tr>
<td>
<asp:Panel ID="pnlSC" runat="server" BorderColor="#0033CC" BorderWidth="0"
Width="461px">
<table class="style9">
<tr>
<td>
<asp:RadioButton ID="rdoSNet" runat="server" Checked="True" Font-Size="Small"
GroupName="View" Text="SC" Visible="False" />
</td>
<td class="style13">
<asp:DropDownList ID="ddlistSNet" runat="server" DataTextField="SNet_Name"
DataValueField="SNet_ID" Font-Size="Small" Visible="False" Width="222px">
</asp:DropDownList>
</td>
<td>
<asp:RadioButton ID="rdoAdmin" runat="server" Font-Size="Small"
GroupName="View" Text="Sys Admin" Visible="False" />
</td>
</tr>
</table>
</asp:Panel>
</td>
<td valign="baseline">
<asp:Label ID="lblError" runat="server" Font-Bold="True" ForeColor="Red"
Height="8px" Width="452px"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
</td>
</tr>
<tr>
<td width="400">
<rad:RadGrid ID="RadGrid1" AllowScroll="true" Font-Size="Smaller" AllowMultiRowSelection="true"
Skin="WebBlue" runat="server" AllowAutomaticDeletes="True" Width="242%" PageSize="40"
AllowPaging="True" AutoGenerateColumns="False" DataSourceID="ObjDataSource1" ShowStatusBar="true"
EnableAJAX="true" EnableAJAXLoadingTemplate="true" LoadingTemplateTransparency="50"
OnItemCreated="RadGrid1_ItemCreated" OnDeleteCommand="RadGrid1_DeleteCommand" OnUpdateCommand="RadGrid1_UpdateCommand"
OnInsertCommand="RadGrid1_InsertCommand" OnItemCommand="RadGrid1_ItemCommand" OnItemDataBound="RadGrid1_ItemDataBound">
<PagerStyle Mode="Slider" />
<ClientSettings>
<Selecting AllowRowSelect="true" />
</ClientSettings>
<MasterTableView CommandItemDisplay="Top" DataKeyNames="PersonID" DataSourceID="ObjDataSource1"
EditMode="EditForms" AutoGenerateColumns="False" Width="100%">
<CommandItemTemplate>
<div style="padding: 10px 0px;">
<asp:LinkButton ID="LinkButtonAddNew" Font-Size="X-Small" runat="server" CommandName="InitInsert"><img style="border:0px;vertical-align:middle;" alt="" src="Images/AddRecord.gif" />
Add new</asp:LinkButton>
<asp:LinkButton ID="LinkButtonDeleteSelected" Font-Size="X-Small" OnClientClick="javascript:return confirm('Delete selected items?')"
runat="server" CommandName="DeleteSelected" CausesValidation="false"><img style="border:0px;vertical-align:middle;" alt="" src="Images/Delete.gif" />
Delete Selected</asp:LinkButton>
<asp:LinkButton ID="LinkButtonRefresh" Font-Size="X-Small" runat="server" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="Images/Refresh.gif" />
Refresh</asp:LinkButton>
</div>
</CommandItemTemplate>
<RowIndicatorColumn Visible="False">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="False" Resizable="False">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<rad:GridClientSelectColumn HeaderStyle-Width="40px" />
<rad:GridBoundColumn DataField="PersonID" HeaderText="PersonID" UniqueName="ID" ReadOnly="true"
Visible="false">
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="FirstName" HeaderText="FirstName" UniqueName="FirstName">
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="LastName" HeaderText="LastName" UniqueName="LastName">
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="UserID" HeaderText="UserID" UniqueName="UserID">
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="Password" HeaderText="Password" UniqueName="Password">
</rad:GridBoundColumn>
<rad:GridTemplateColumn UniqueName="PermisCol" HeaderText="Permission">
<ItemTemplate>
<asp:Label ID="LblPermis" runat="server" Width="180"> <%# DataBinder.Eval(Container.DataItem, "PermissionName")%>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ListPermis" runat="server" DataTextField="Permission_Name"
DataValueField="Permission_ID" />
</EditItemTemplate>
</rad:GridTemplateColumn>
<rad:GridTemplateColumn UniqueName="tSNET" HeaderText="SNET">
<ItemTemplate>
<asp:Label ID="LblSNET" runat="server"> <%# DataBinder.Eval(Container.DataItem, "SNetname")%></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ListSNET" runat="server" DataTextField="SNET_Name" DataValueField="SNET_ID" />
</EditItemTemplate>
</rad:GridTemplateColumn>
<rad:GridBoundColumn DataField="SCSname" HeaderText="SCSname" UniqueName="SCSname">
</rad:GridBoundColumn>
<rad:GridBoundColumn Visible="false" DataField="Address1" HeaderText="Address1" UniqueName="Address1">
</rad:GridBoundColumn>
<rad:GridBoundColumn Visible="false" DataField="Address2" HeaderText="Address2" UniqueName="Address2">
</rad:GridBoundColumn>
<rad:GridBoundColumn Visible="false" DataField="City" HeaderText="City" UniqueName="City">
</rad:GridBoundColumn>
<rad:GridBoundColumn Visible="false" DataField="State" HeaderText="State" UniqueName="State">
</rad:GridBoundColumn>
<rad:GridBoundColumn Visible="false" DataField="Zip1" HeaderText="Zip1" UniqueName="Zip1">
</rad:GridBoundColumn>
<rad:GridBoundColumn Visible="false" DataField="Zip2" HeaderText="Zip2" UniqueName="Zip2">
</rad:GridBoundColumn>
<rad:GridBoundColumn Visible="false" DataField="CellPhone" HeaderText="Cell" UniqueName="CellPhone">
</rad:GridBoundColumn>
<rad:GridBoundColumn Visible="false" DataField="Email" HeaderText="Email" UniqueName="Email">
</rad:GridBoundColumn>
<rad:GridBoundColumn Visible="false" DataField="Fax" HeaderText="Fax" UniqueName="Fax">
</rad:GridBoundColumn>
<rad:GridBoundColumn Visible="false" DataField="LandPhone" HeaderText="Phone" UniqueName="LandPhone">
</rad:GridBoundColumn>
<rad:GridBoundColumn Visible="false" DataField="PhoneExtension" HeaderText="PhoneEx" UniqueName="PhoneEx">
</rad:GridBoundColumn>
<rad:GridBoundColumn Visible="false" DataField="Title" HeaderText="Title" UniqueName="Title">
</rad:GridBoundColumn>
<rad:GridButtonColumn ButtonType="ImageButton" ImageUrl="~/Images/Edit.gif" CommandName="Edit"
Text="Edit" UniqueName="EditColumn">
</rad:GridButtonColumn>
</Columns>
<DetailTables>
<rad:GridTableView DataKeyNames="PersonID" DataSourceID="ObjDataSource2" Name="PerDetail">
<ParentTableRelation>
<rad:GridRelationFields DetailKeyField="PersonID" MasterKeyField="PersonID" />
</ParentTableRelation>
<Columns>
<rad:GridBoundColumn Visible="false" DataField="Address2" HeaderText="Address2" UniqueName="Address2">
</rad:GridBoundColumn>
</Columns>
</rad:GridTableView>
</DetailTables>
</MasterTableView>
</rad:RadGrid>
<asp:ObjectDataSource ID="ObjDataSource1" runat="server" TypeName="BalancedFlow.Library.Manager.UserManager"
SelectMethod="GetPersons" EnablePaging="false">
<SelectParameters>
<asp:ControlParameter Name="iPermis_IDtoDisplay" ControlID="lblPermissionIDForDisplay"
PropertyName="Text" />
<asp:ControlParameter Name="iSNet_ID" ControlID="lblSNet_IDForDisplay" PropertyName="Text" />
<asp:ControlParameter Name="iSCS_ID" ControlID="lblSCS_IDForDisplay" PropertyName="Text" />
<asp:ControlParameter Name="iPerson_ID" ControlID="lblPerson_ID" PropertyName="Text" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ObjDataSource2" runat="server" TypeName="BalancedFlow.Library.Manager.UserManager"
SelectMethod="GetOnePerson" EnablePaging="false">
<SelectParameters>
<asp:ControlParameter Name="PersonID" ControlID="Radgrid1" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
</td>
</tr>
<tr>
<td>
<table id="Table4" cellspacing="1" cellpadding="1" width="300" border="0">
<tr>
<td height="21">
<asp:Label ID="lblPermissionIDForDisplay" runat="server" Visible="False"></asp:Label>
<asp:Label ID="lblPerson_ID" runat="server" Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblSNet_IDForDisplay" runat="server" Width="176px" Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td style="height: 41px">
<asp:Label ID="lblSCS_IDForDisplay" runat="server" Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td style="height: 41px">
<asp:Label ID="lblV" runat="server" Visible="False" Width="184px"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>