New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

Interface that RadGrid uses to determine the editable columns, their current state etc.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public interface IGridEditableColumn

Derived Classes: GridAttachmentColumnGridAutoCompleteColumnGridBinaryImageColumnGridBoundColumnGridCheckBoxColumnGridDateTimeColumnGridDropDownColumnGridEditableColumnGridHTMLEditorColumnGridMaskedColumnGridNumericColumnGridRatingColumnGridTemplateColumn...

Example:

csharp
protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
                GridEditableItem editedItem = e.Item as GridEditableItem;
                GridEditManager editMan = editedItem.EditManager;

                foreach( GridColumn column in e.Item.OwnerTableView.RenderColumns )
                {
                    if ( column is IGridEditableColumn )
                    {
                        IGridEditableColumn editableCol = (column as IGridEditableColumn);
                        if ( editableCol.IsEditable )
                        {
                            IGridColumnEditor editor = editMan.GetColumnEditor( editableCol );

                            string editorType = editor.ToString();
                            string editorText = "unknown";
                            object editorValue = null;

                            if ( editor is GridTextColumnEditor )
                            {
                                editorText = (editor as GridTextColumnEditor).Text;
                                editorValue = (editor as GridTextColumnEditor).Text;
                            }

                            if ( editor is GridBoolColumnEditor )
                            {
                                editorText = (editor as GridBoolColumnEditor).Value.ToString();
                                editorValue = (editor as GridBoolColumnEditor).Value;
                            }

                            if ( editor is GridDropDownColumnEditor )
                            {
                                editorText = (editor as GridDropDownColumnEditor).SelectedText + "; " +
                                    (editor as GridDropDownColumnEditor).SelectedValue;
                                editorValue = (editor as GridDropDownColumnEditor).SelectedValue;
                            }

                            try
                            {
                                DataRow[] changedRows = this.EmployeesData.Tables["Employees"].Select( "EmployeeID = " + editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["EmployeeID"] );
                                changedRows[0][column.UniqueName] = editorValue;
                                this.EmployeesData.Tables["Employees"].AcceptChanges();
                            }
                            catch(Exception ex)
                            {
                                RadGrid1.Controls.Add(new LiteralControl ("<strong>Unable to set value of column '" + column.UniqueName + "'</strong> - " + ex.Message));
                                e.Canceled = true;
                                break;
                            }
                        }
                    }
                }
        }
csharp
Private Sub RadGrid1_UpdateCommand(ByVal source As System.Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand

            Dim editedItem As GridEditableItem = CType(e.Item, GridEditableItem)
            Dim editMan As GridEditManager = editedItem.EditManager

            Dim column As GridColumn

            For Each column In e.Item.OwnerTableView.Columns
                If Typeof column Is IGridEditableColumn Then
                    Dim editableCol As IGridEditableColumn = CType(column, IGridEditableColumn)
                    If (editableCol.IsEditable) Then
                        Dim editor As IGridColumnEditor = editMan.GetColumnEditor(editableCol)

                        Dim editorType As String = CType(editor, Object).ToString()
                        Dim editorText As String = "unknown"
                        Dim editorValue As Object = Nothing

                        If (Typeof editor Is GridTextColumnEditor) Then
                            editorText = CType(editor, GridTextColumnEditor).Text
                            editorValue = CType(editor, GridTextColumnEditor).Text
                        End If

                        If (Typeof editor Is GridBoolColumnEditor) Then
                            editorText = CType(editor, GridBoolColumnEditor).Value.ToString()
                            editorValue = CType(editor, GridBoolColumnEditor).Value
                        End If

                        If (Typeof editor Is GridDropDownColumnEditor) Then
                            editorText = CType(editor, GridDropDownColumnEditor).SelectedText & "; " & CType(editor, GridDropDownColumnEditor).SelectedValue
                            editorValue = CType(editor, GridDropDownColumnEditor).SelectedValue
                        End If

                        Try
                            Dim changedRows As DataRow() = Me.EmployeesData.Tables("Employees").Select("EmployeeID = " & editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("EmployeeID"))
                            changedRows(0)(column.UniqueName) = editorValue
                            Me.EmployeesData.Tables("Employees").AcceptChanges()
                        Catch ex As Exception
                            RadGrid1.Controls.Add(New LiteralControl("<strong>Unable to set value of column '" & column.UniqueName & "'</strong> - " + ex.Message))
                            e.Canceled = True
                        End Try

                    End If
                End If
            Next
        End Sub

Properties

Gets the GridColumn instance implementing this interface

C#
GridEditableColumn Column { get; }

Gets the column editor instance for this column

C#
IGridColumnEditor ColumnEditor { get; set; }

Force RadGrid to extract values from EditableColumns that are ReadOnly (or IsEditable is false).

C#
GridForceExtractValues ForceExtractValue { get; set; }

Get whether a column is currently read-only

C#
bool IsEditable { get; }

Methods

Extracts the values from the editedItem and fills the names/values pairs for each data-field edited by the column in the newValues dictionary.

C#
void FillValues(IDictionary newValues, GridEditableItem editableItem)
Parameters:newValuesIDictionary

dictionary to fill. This param should not be null (Nothing in VB.NET)

editableItemGridEditableItem

the GridEditableItem to extract values from

Get value based on the current IsEditable state, item edited state and ForceExtractValue setting.

C#
bool ShouldExtractValues(GridEditableItem item)
Parameters:itemGridEditableItem

item to check to extract values from

Returns:

bool