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

GridDropDownColumn loading data from a webservice

6 Answers 98 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 04 Jan 2011, 11:38 AM
Hi,

first I would like to wish all of you a happy new year.

I want to use a GridDropDownColumn. The list of possible entries is populated by a webservice. What's the suggested way to implement this feature?

Thanks,
Chris

6 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 04 Jan 2011, 12:50 PM
Hello,


You can easily customize the GridDropDownColumn in grid. The documentation shows some insight on this. Have a look on this.
Customize/Configure GridDropDownColumn

You could acess teh DropDownList control and set the DataSource as required.


Thanks,
Princy.
0
Christian
Top achievements
Rank 1
answered on 04 Jan 2011, 01:36 PM
Hi Princy,

i have already read this article, but i didn't get the point how this will work for a list of objects which are populated by WCF-Webservice.

May be i should explain my application architeture. I seperated the presentation logic from the business logic. These layers are communicating thru several WCF-Webservices. I am using proxies for consuming the webservices in the presentation layer.

My current Grid - Definition in the aspx - File looks like this:
<telerik:RadGrid ID="GridLogin" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            OnNeedDataSource="GridLogin_NeedDataSource" OnUpdateCommand="GridLogin_UpdateCommand"
            OnDeleteCommand="GridLogin_DeleteCommand" OnInsertCommand="GridLogin_InsertCommand"
            OnPreRender="GridLogin_PreRender">
            <PagerStyle Mode="NextPrevAndNumeric" />
            <MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="ID" AutoGenerateColumns="false"
                GridLines="Both" EditMode="InPlace">
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="Edit">
                        <HeaderStyle Width="20px" />
                    </telerik:GridEditCommandColumn>
                    <telerik:GridButtonColumn ConfirmText="Diesen Eintrag auf Gelöscht setzen?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                        <HeaderStyle Width="20px" />
                    </telerik:GridButtonColumn>
                    <telerik:GridBoundColumn DataField="Username" HeaderText="Username" UniqueName="Username" />
                    <telerik:GridBoundColumn DataField="LogintypeID" HeaderText="LogintypeID" UniqueName="LogintypeID" />
                    <telerik:GridBoundColumn DataField="LogintypeText" HeaderText="LogintypeText" UniqueName="LogintypeText" />
                    <telerik:GridBoundColumn DataField="Firstname" HeaderText="Vorname" UniqueName="Firstname" />
                    <telerik:GridBoundColumn DataField="Lastname" HeaderText="Nachname" UniqueName="Lastname" />
                    <telerik:GridBoundColumn DataField="Title" HeaderText="Titel" UniqueName="Title" />
                    <telerik:GridCheckBoxColumn DataField="IsCMLoginAdmin" HeaderText="CM-Admin" UniqueName="IsCMLoginAdmin"
                        DataType="System.Boolean" />
                    <telerik:GridCheckBoxColumn DataField="Deleted" HeaderText="Gelöscht" UniqueName="Deleted"
                        DataType="System.Boolean" />
                </Columns>
                <CommandItemSettings AddNewRecordText="Hinzufügen" RefreshText="Aktuallisieren" />
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnRowDblClick="RowDblClick" />
            </ClientSettings>
        </telerik:RadGrid>

In the OnNeedDataSource-Event i create an instance of my Webservice-Proxy and call the corresponding method to retrieve the data from my Webservice.

protected void GridLogin_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    if (HasReadAccess())
    {
        CGI.CM.Login.Business.Proxy.CMLoginProxy proxy = GetProxy();
        GridLogin.DataSource = proxy.GetInternalLogins(GetToken());
    }
    else
    {
        throw new Exception("No read access");
    }
}

That works fine. But i don't want to display the ID of the Logintype (LogintypeID - Property), instead i want to display the real name of the Logintype (eg. 'internal', 'external'). Therefore my proxy class gives me another method which returns a list of all possible Logintypes.

My goal is to replace the GridBoundColumn for logintype with a GridDropDownColumn.

Thanks for your help.

Chris

 

 

 

0
Accepted
Marin
Telerik team
answered on 04 Jan 2011, 03:07 PM
Hello Christian,

If the GridDropdownColumn is configured to have a RadComboBox in its DropDownControlType then you can configure it to bind to web service in the following way:

void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)  
{  
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
    {  
        GridEditableItem item = e.Item as GridEditableItem;  
        RadComboBox combo = (item.EditManager.GetColumnEditor("DropDownColumnNAme") as GridDropDownListColumnEditor).ComboBoxControl;  
        //you can now set combo.WebServiceSettings.Path  
    }  



Kind regards,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Christian
Top achievements
Rank 1
answered on 05 Jan 2011, 11:24 AM
Hi,

thanks that works fine for me.

Regards,
Christian
0
Ioish
Top achievements
Rank 1
answered on 28 Feb 2014, 06:39 PM
I know this thread is already several years old, but I'm encountering problems using the suggested solution for batch editing.

The problem lies in that the following statement never seems to be true when using batch editing

if (e.Item is GridEditableItem && e.Item.IsInEditMode)

Therefore the reference to the webservice is never made. Trying to type anything in the combox results in an untreated exception inside the combobox control.

Is it possible to use this columntype with batch editing getting it's data from a webservice?
0
Pavlina
Telerik team
answered on 05 Mar 2014, 08:53 AM
Hello,

You can check the forum thread below which elaborates on similar subject:
http://www.telerik.com/forums/grid-batch-edit-mode

Regards,
Pavlina
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

Tags
Grid
Asked by
Christian
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Christian
Top achievements
Rank 1
Marin
Telerik team
Ioish
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or