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

AllowCustomText inside RadGrid

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 1
Derek asked on 06 Jun 2010, 08:53 PM
One of my developers is trying to use an autocomplete column inside a Radgrid. We configured a dropdown column which uses a "select distinct" statement to get the unique existing values in the field, and then used that as source for the dropdowncolumn. Here's the column.

<telerik:GridDropDownColumn DataField="MadeBy" HeaderText="MadeBy"
            SortExpression="MadeBy" UniqueName="MadeBy" DataSourceID="dsMadeBy" ListTextField="MadeBy"     ListValueField="MadeBy">
</telerik:GridDropDownColumn>


In code-behind, we've set up the AllowCustomText and MarkFirstMatch properties as follows;

    Protected Sub RadGridItems_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGridItems.ItemDataBound
        ' try and set the allowcustomtext property on the dropdown
        If TypeOf (e.Item) Is GridEditableItem And e.Item.IsInEditMode Then
            Dim edititem As GridEditableItem = e.Item
            Dim combo As RadComboBox = edititem("MadeBy").Controls(0)
            combo.AllowCustomText = True
            combo.MarkFirstMatch = True
        End If
    End Sub

This seems to work, and we are able to enter new text, but nothing is saved and the Update section remains on the screen. Are we missing something?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Jun 2010, 07:51 AM
Hello Derek,

One suggestion in this case would be access the RadComboBox value and update it from code behind. Sample code is given below.

VB.Net
Protected Sub RadGrid1_UpdateCommand(source As Object, e As GridCommandEventArgs) 
    Dim edititem As GridEditableItem = DirectCast(e.Item, GridEditableItem) 
    Dim combo As RadComboBox = DirectCast(edititem("MadeBy").Controls(0), RadComboBox) 
    Dim newvalue As String = combo.Text 
    'update query 
End Sub 
 

Regards,
Shinu.



Tags
Grid
Asked by
Derek
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or