ASPxClientGridView.GetEditor(column) Method
Returns the editor used to edit the specified column’s values.
Declaration
GetEditor(
column: ASPxClientGridViewColumn | number | string
): ASPxClientEdit
Parameters
Name | Type | Description |
---|---|---|
column | string | number | ASPxClientGridViewColumn | Specifies the required column in the client grid. |
Returns
Type | Description |
---|---|
ASPxClientEdit | Specifies a column’s editor. |
Remarks
Use the GetEditor method to access the specified column’s editor when the grid is in edit mode. If the grid is in browse mode, the GetEditor method returns null.
Note
The grid does not render default editors when the EditForm template (MVCxGridViewProperties.SetEditFormTemplateContent) is used. The GetEditor returns null when you access custom editors in the template. In this case, use the Name or the ClientInstanceName of an extension that is placed in the EditForm template to access custom editors on the client side.
Example
Note
Refer to the ASPxGridView - Cascading Combo Boxes (Web Forms) and GridView- Cascading Combo Boxes (MVC) online demos to get a full example.
Web Forms:
<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server" DataSourceID="DemoDataSource1"
KeyFieldName="CustomerID" Width="100%" AutoGenerateColumns="false" ...>
<SettingsEditing Mode="Inline" />
<Columns>
<dx:GridViewDataComboBoxColumn FieldName="Country" Width="150">
<PropertiesComboBox TextField="CountryName" ValueField="CountryName" EnableSynchronization="false"
IncrementalFilteringMode="StartsWith" DataSourceID="CountriesDataSource">
<ClientSideEvents SelectedIndexChanged="function(s, e) { OnCountryChanged(s); }" />
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
<dx:GridViewDataComboBoxColumn FieldName="City" Width="150">
<PropertiesComboBox EnableSynchronization="false" IncrementalFilteringMode="StartsWith">
<ClientSideEvents EndCallback="OnEndCallback" />
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
...
</Columns>
</dx:ASPxGridView>
var lastCountry = null;
function OnCountryChanged(cmbCountry) {
if(grid.GetEditor("City").InCallback())
lastCountry = cmbCountry.GetValue().toString();
else
grid.GetEditor("City").PerformCallback(cmbCountry.GetValue().toString());
}
function OnEndCallback(s, e) {
if(lastCountry) {
grid.GetEditor("City").PerformCallback(lastCountry);
lastCountry = null;
}
}
MVC:
Html.DevExpress().GridView<DevExpress.Web.Demos.Mvc.EditableCustomer>(settings => {
settings.Name = "GridView";
settings.SettingsEditing.Mode = GridViewEditingMode.Inline;
...
settings.Columns.Add(m => m.Country, column => {
column.EditorProperties().ComboBox(p => {
p.TextField = "CountryName";
p.ValueField = "CountryName";
p.DataSource = WorldCitiesDataProvider.GetCountries();
p.ClientSideEvents.SelectedIndexChanged = "OnSelectedCountryChanged";
});
});
settings.Columns.Add(m => m.City, column => {
column.EditorProperties().ComboBox(p => {
p.CallbackRouteValues = new { Controller = "Editing", Action = "GetCities", TextField = "CityName" };
p.TextField = "CityName";
p.ClientSideEvents.BeginCallback = "CityComboBox_BeginCallback";
});
});
...
}).SetEditErrorText(ViewData["EditError"] as string).Bind(Model).GetHtml();
function OnSelectedCountryChanged() {
GridView.GetEditor("City").PerformCallback();
}
function CityComboBox_BeginCallback(s, e) {
e.customArgs["CountryName"] = GridView.GetEditor("Country").GetValue();
}