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.
Hello, Georgi
Sample attached please set path to cust.xml here
ds.ReadXml("c:\\cust.xml", XmlReadMode.ReadSchema); (line 130 in LastUpdatable.aspx.cs)
according your local environment.
To reproduce:
1 - Open LastUpdatable.aspx in your browser
2 - Press Edit button to switch grid into edit mode
3 - Edit values in Address1 column for example. See values save changed state when you edit it and switch to another cell
4 - Press Save Changes and see (using debugger) grid1_RowUpdating is called correctly and entered values are passed to server.
5 - Refresh page, press Edit button do not edit other columns except first one.
6 - Try to edit First column (called "Flag"). Double click on false value and see unchecked Checkbox, double click on true value and also see unchecked checkbox.
7 - Check any checkbox and see checkboxes for all rows are checked now
8 - Press Save Changes and notice grid1_RowUpdating is not called (use debugger to see this)
Question is: How can I add checkbox editor for boolean field in WebDataGrid and get grid1_RowUpdating called with correct checkx state passed to server?
Regards,Andrey
Hello Andrey,
Can you send me your sample as a start point while I am investigating this?
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?
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.