Hello,
I'm trying to add CheckBoxProvider to my custom TemplateDataField and cannot make checkbox apear on double click.
Is this a correct way of adding CheckBoxProvider for TemplateDataField?
Assume grid is created and added to page, EditBehavior added and enabled, CellEditingBehavior added and enabled, other fields in the same grid (with TextEditorProvider or NumericEditorProvider for ex.) are editable on double click
---------------------------------------------------
col = new TemplateDataField{ ItemTemplate = new CheckBoxTemplate(), Type = typeof(bool), Key = "ColumnName" };
grid.Columns.Add(col);var provider = new CheckBoxProvider("ProviderForColumn");grid.EditorProviders.Add(provider);grid.Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings.Add(new EditingColumnSetting { ColumnKey = col.Key, EditorID = provider.ID});---------------------------------------------------
CheckBoxTemplate is extremly simple: just one image on true and another on false (below)
public class CheckBoxTemplate: ITemplate, INamingContainer { public string CheckedImageUrl; public string NotCheckedImageUrl; public string ValueFieldName; public void InstantiateIn(Control c) { if (String.IsNullOrEmpty(this.ValueFieldName) && (c is Infragistics.Web.UI.TemplateContainer)) { GridRecordItem item = (GridRecordItem)((Infragistics.Web.UI.TemplateContainer)c).Item; this.ValueFieldName = item.Column.Key; } HtmlImage img = new HtmlImage(); img.DataBinding += OnDisplayDataBinding; c.Controls.Add(img); } void OnDisplayDataBinding(object sender, EventArgs e) { HtmlImage img = (HtmlImage)sender; object dataItem = (img.NamingContainer is IDataItemContainer) ? ((IDataItemContainer)img.NamingContainer).DataItem : ((Infragistics.Web.UI.TemplateContainer)img.NamingContainer).DataItem; object dataValue = DataBinder.GetPropertyValue(dataItem, this.ValueFieldName); if (dataValue is bool) img.Src = (bool)dataValue ? CheckedImageUrl : NotCheckedImageUrl; } }
I'm using 10.3.20103.2217 version of controls and cannot move to ASP.NET 4.0 now. I cannot use declarative syntax as do not know what to add at compile time and have to add columns dynamically.
Any help appreciated.
Hi Andrey,
I found this forum thread on your behalf:
http://community.infragistics.com/forums/t/66390.aspx?PageIndex=1
You can walk through it.
If you need any further assistance or you have any questions do not hesitate to contact me.
Sincerely,
Georgi Sashev
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
By the way.
In case if you use BoundDataField as column type instead of TemplateDataField you will be able to see checkbox on double-click, (!)but(!) changing checkbox state doesn't trigger RowUpdating event like changins text in textbox does.
Hi,
This thread doesn't describe behavior I want to implement.This thread is about recieving Event, generated by control, added using ItemTemplate.
In my case I want ot recieve check state of Checkbox (which should shown for editable boolean column) in my RowUpdating handler the same way as I recieve edited valued for fileds utilizing DropDownProvider, MaskEditorProvider, NumericEditorProvider or TextEditorProvider (using RowUpdatingEventArgs.Values collection)
I did not find CheckboxProvider and created my own, which looks like this:
public class CheckBoxProvider: EditorProvider<CheckBox> { public CheckBoxProvider() { } public CheckBoxProvider(string id) { if (!String.IsNullOrEmpty(id)) base.ID = id; } protected override bool CanEditType(Type t) { return t == typeof(bool); }
}
When I use it the way described in my initial post I cannot see checkbox editor when I double-click on my boolean field.
Should I modify my CheckBox provider? What should be added?