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

GridAutocompleteColumn returns DataTextField instead of DataValueField

2 Answers 237 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 25 Mar 2015, 10:59 PM
General scenario: I have a radgrid using auto-generated in-place record editing. Datasources are LLBLgen entity collections. One of the columns is username (as in AD account name), but is a GridAutocompleteColumn with the users' display name as the DataTextField so it will be easier for user to make the correct selection. The autocomplete part works (mostly) correctly. What I thought would happen next is when user clicks Update link to confirm selection, the Adname value would be inserted into the grid (and therefore the backing table). But instead, the displayname is being inserted. What am I doing wrong?


<telerik:RadGrid ID="gridUserAssignment" runat="server" DataSourceID="llblgUserAssignmentData"
        AllowAutomaticUpdates="true" AutoGenerateEditColumn="true" AllowAutomaticDeletes="false" AutoGenerateDeleteColumn="false"
        OnNeedDataSource="gridUserAssignment_NeedDataSource"
        OnDeleteCommand="gridUserAssignment_DeleteCommand"
        OnEditCommand="gridUserAssignment_EditCommand"
        OnItemCommand="gridUserAssignment_ItemCommand"
        OnPdfExporting="gridUserAssignment_PdfExporting">
        <ClientSettings>
            <Selecting AllowRowSelect="True" />
        </ClientSettings>
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="RoleId" DataSourceID="llblgUserAssignmentData" EditMode="InPlace"  CommandItemDisplay="Top" >
            <CommandItemSettings ShowExportToPdfButton="true" ShowExportToCsvButton="true" ShowAddNewRecordButton="False" ShowRefreshButton="false">
            </CommandItemSettings>
            <Columns>                    
                <telerik:GridTemplateColumn HeaderText="#" UniqueName="RowNumber" HeaderStyle-Width="3%">
                    <ItemTemplate>
                        <asp:Label runat="server" ID="lblRowNumberAccessUsers" Width="50px" Text='<%# Container.DataSetIndex+1 %>'></asp:Label>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
 
                <telerik:GridAutocompleteColumn DataField="Adname" FilterControlAltText="Filter Adname column" HeaderText="User AD Username" SortExpression="Adname" UniqueName="Adname"
                    DataSourceID="llblgADusers"
                    DataValueField="SAmaccountName"
                    DataTextField="SAmaccountName"
                    Filter="Contains"                           
                    InputType="Text"
                    SelectionMode="Single"
                    AllowCustomEntry="false"
                >
                <telerik:GridBoundColumn DataField="ADuserDetail.Title" ReadOnly="true" FilterControlAltText="Filter User Title column" HeaderText="User Title" SortExpression="Usertitle" UniqueName="Usertitle">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ADuserDetail.Email" ReadOnly="true" FilterControlAltText="Filter email column" HeaderText="User email" SortExpression="email" UniqueName="email">
                </telerik:GridBoundColumn>          
            </Columns
 
    </MasterTableView>          
</telerik:RadGrid>
<llblgenpro:LLBLGenProDataSource ID="llblgUserAssignmentData" runat="server" DataContainerType="EntityCollection" EntityCollectionTypeName="UserManagement.CollectionClasses.UserRoleUserCollection, UserManagement" >
</llblgenpro:LLBLGenProDataSource>
<llblgenpro:LLBLGenProDataSource ID="llblgADusers" runat="server" DataContainerType="EntityCollection" EntityCollectionTypeName="UserManagement.CollectionClasses.AduserDetailCollection, UserManagement" >
</llblgenpro:LLBLGenProDataSource>

Side note (I think): when in edit mode, when I start typing, if I pause for a small while, the autocomplete returns a set of matches but does not rerun and refresh the results as I type additional characters. For now, I get around this by typing really fast so the search gets the whole search string at once.
- Justin

2 Answers, 1 is accepted

Sort by
0
Accepted
Angel Petrov
Telerik team
answered on 30 Mar 2015, 12:53 PM
Hi Justin,

Indeed with the current design of the column the update value on the server will be the text of the RadAutoCompleteBox rendered as an editor for the column. If you want to obtain the Adname value you can manually obtain it on the server by subscribing to the OnUpdateCommand or OnInsertCommand events.

Regards,
Angel Petrov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Justin
Top achievements
Rank 1
answered on 30 Mar 2015, 03:48 PM
Thanks for the confirmation and clarification. The original feature release note (http://blogs.telerik.com/aspnet-ajax/posts/13-06-27/the-most-wanted-features-in-radgrid-for-asp.net-ajax-in-q2-2013) perhaps doesn't make that point clearly enough.

Thanks for your help.
- Justin
Tags
Grid
Asked by
Justin
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Justin
Top achievements
Rank 1
Share this question
or