This is a migrated thread and some comments may be shown as answers.

Grid and Custom Editing.......

1 Answer 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Geoff
Top achievements
Rank 1
Geoff asked on 24 Aug 2010, 02:26 PM
Hi All

We have a simple task to achieve but are struggling and wondered if anyone has any pointers...

Basically issue is we have Grid which display 'Alerts' to our users which looks like.......

ID     | Alert Name         | Created         | Status
100    Order Created    12/12/2010     On Order

In the database we have an Alerts table and Alert Status table. The Alert table contains all of the above fields except for the Status which is an reference to the Alert Status table. So in Alerts we have a StatusRef(int) that links to AlertStatus to display the status name.

What we need to achieve is when Edit is selected the only field that can edited is the Status field which should contain a drop down list which loads all of the Statuses - ID / Name from the db - to allow the user to change the status.

We have managed to do this so when a user wants to change the status a drop down is provided and contains the values we need but..........

1> How do I link up the drop down in edit mode to the Status field so that when Update is selected the update is performed.
2> How do I select the Value rather than the Text from the drop down

So far we have......

<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" GridLines="None"
         AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" AllowAutomaticDeletes="true"
         AllowAutomaticUpdates="true">
         <MasterTableView AutoGenerateColumns="False" DataKeyNames="AlertID" DataSourceID="SqlDataSource1"
             EditMode="EditForms">
             <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
             <RowIndicatorColumn>
                 <HeaderStyle Width="20px"></HeaderStyle>
             </RowIndicatorColumn>
             <ExpandCollapseColumn>
                 <HeaderStyle Width="20px"></HeaderStyle>
             </ExpandCollapseColumn>
             <Columns>
                 <telerik:GridBoundColumn DataField="AlertID" DataType="System.Int32" HeaderText="ID"
                     ReadOnly="True" SortExpression="AlertID" UniqueName="AlertID">
                 </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn DataField="AlertTitle" HeaderText="Alert" SortExpression="AlertTitle"
                     UniqueName="AlertTitle" ReadOnly="true">
                 </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn DataField="AlertTo" DataType="System.Int32" HeaderText="AlertTo"
                     SortExpression="AlertTo" UniqueName="AlertTo" Visible="false" ReadOnly="true">
                 </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn DataField="AlertCreated" DataType="System.DateTime" HeaderText="AlertCreated"
                     SortExpression="AlertCreated" UniqueName="AlertCreated" ReadOnly="true">
                 </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn DataField="AlertStatus" HeaderText="AlertStatus" SortExpression="AlertStatus"
                     UniqueName="AlertStatus" Visible="false" DataType="System.Int32">
                 </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn DataField="AlertFilter" HeaderText="AlertFilter" SortExpression="AlertFilter"
                     UniqueName="AlertFilter" Visible="false" ReadOnly="true">
                 </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn DataField="AlertStatusName" HeaderText="AlertStatusName"
                     SortExpression="AlertStatusName" UniqueName="AlertStatusName" ReadOnly="true">
                 </telerik:GridBoundColumn>
                 <telerik:GridHyperLinkColumn UniqueName="AlertActionLink" Target="_parent" HeaderText="Action"
                     Text="Action" DataNavigateUrlFields="AlertActionLink">
                 </telerik:GridHyperLinkColumn>
             </Columns>
             <EditFormSettings EditFormType="Template">
                 <FormTemplate>
                     <br />
                     <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2"
                         DataTextField="AlertStatusName" DataValueField="AlertStatusID">
                     </asp:DropDownList>
                     <br />
                     <asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click" />
                 </FormTemplate>
             </EditFormSettings>
         </MasterTableView>
     </telerik:RadGrid>
     <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:IFMWEBDBADMIN2 %>"
         SelectCommand="SELECT [AlertStatusID], [AlertStatusName] FROM [IFM_Alert_Status]">
     </asp:SqlDataSource>
     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:IFMWEBDBADMIN2 %>"
         SelectCommand="IFM_Alerts_ViewAll" DeleteCommand="IFM_Alerts_ViewAll_Delete"
         DeleteCommandType="StoredProcedure" SelectCommandType="StoredProcedure" UpdateCommand="IFM_Alerts_ViewAll_Update"
         UpdateCommandType="StoredProcedure">
         <DeleteParameters>
             <asp:Parameter Name="AlertID" Type="Int32" />
         </DeleteParameters>
         <SelectParameters>
             <asp:SessionParameter Name="UserID" SessionField="LoggedInUsersUserID" Type="Int32"
                 DefaultValue="999900" />
         </SelectParameters>
         <UpdateParameters>
             <asp:Parameter Name="AlertID" Type="Int32" />
             <asp:Parameter Name="AlertStatus" Type="Int32" />
         </UpdateParameters>
     </asp:SqlDataSource>

Any help is greatly appreciated as I am a bit stuck at the moment :)

All the best

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 27 Aug 2010, 03:04 PM
Hello Geoff,

To implement the desired functionality, I recommend that you use GridDropDownColumn. in edit mode it displays a drop-down control for each edited cell in the column. You can see how to bind it in the Column types help topic.
For a working demo, please examine the Column Types demo.

I hope this helps.

Kind regards,
Mira
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Geoff
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or