Hi,
I'm evaluating the Telerik GridView for use in a new project and am coming up against a couple of difficulties. I haven't found answers in the Forum, so I thought I would ask.
The situation. We are binding CSLA collections to a data grid. We want to use comboboxes for certain columns. Due to customer restraints, we are forced to use WinForms.
First. For GridViewComboBoxColumns. Is it possible to bind not to a value of the SelectedItem but to the item itself? We use readonly "Mini Objects" for things like Products and try not to expose the ID for that product. It shouldn't be necessary for the UI Developer to know what the ID is. You might think about adding the option SelectedItem to the ValueMember options. Then the SelectedItem is bound to the object and not the ID. I would think this would also be interesting for things like EF Entities where you also want to bind to an object and not directly to an ID.
I found a partial workaround for the above problem, see below, but it seems very cludgy.
Second: Our Business objects are based on bindinglists. That means they have logic for determining default values for new items added to collections. For example for the OrderDetail object will automatically set the default discount depending on the Customer defined in the OrderObject.
Does the RadGridView support this kind of senario? How can I convince the grid to use my 'correct' value instead of an empty version?
Also, since the RadGridView adds a "Phantom" object, the above code doesn't work. I can't set the editable price for the OrderDetail. It gets ignored.
Note, the default object works perfectly in the Windows datagrid but causes problems with the Telerik product. Interestingly, if I have both controls on the same form, bound to the same bindinglist and click on the "new row" in the Windows DataGrid, the Telerik gets all the events and shows the right information.
Thanks for any help.
I'm evaluating the Telerik GridView for use in a new project and am coming up against a couple of difficulties. I haven't found answers in the Forum, so I thought I would ask.
The situation. We are binding CSLA collections to a data grid. We want to use comboboxes for certain columns. Due to customer restraints, we are forced to use WinForms.
First. For GridViewComboBoxColumns. Is it possible to bind not to a value of the SelectedItem but to the item itself? We use readonly "Mini Objects" for things like Products and try not to expose the ID for that product. It shouldn't be necessary for the UI Developer to know what the ID is. You might think about adding the option SelectedItem to the ValueMember options. Then the SelectedItem is bound to the object and not the ID. I would think this would also be interesting for things like EF Entities where you also want to bind to an object and not directly to an ID.
I found a partial workaround for the above problem, see below, but it seems very cludgy.
Private Sub RadGridView1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGridView1.ValueChanged
Dim dataRow As GridViewDataRowInfo = TryCast(Me.RadGridView1.CurrentRow, GridViewDataRowInfo)
If dataRow Is Nothing Then
Return
End If
Dim orderDetail As BO.OrderDetail = TryCast(dataRow.DataBoundItem, BO.OrderDetail)
Dim cbEditor As RadDropDownListEditor = TryCast(Me.RadGridView1.ActiveEditor, Telerik.WinControls.UI.RadDropDownListEditor)
If cbEditor IsNot Nothing Then
Dim editorElement As RadDropDownListEditorElement = TryCast(cbEditor.EditorElement, RadDropDownListEditorElement)
Dim prod As BO.ProductInfo = DirectCast(editorElement.SelectedItem.DataBoundItem, BO.ProductInfo)
orderDetail.ProductInfo = prod
orderDetail.UnitPrice = prod.UnitPrice
End If
End Sub
Second: Our Business objects are based on bindinglists. That means they have logic for determining default values for new items added to collections. For example for the OrderDetail object will automatically set the default discount depending on the Customer defined in the OrderObject.
Does the RadGridView support this kind of senario? How can I convince the grid to use my 'correct' value instead of an empty version?
Also, since the RadGridView adds a "Phantom" object, the above code doesn't work. I can't set the editable price for the OrderDetail. It gets ignored.
Note, the default object works perfectly in the Windows datagrid but causes problems with the Telerik product. Interestingly, if I have both controls on the same form, bound to the same bindinglist and click on the "new row" in the Windows DataGrid, the Telerik gets all the events and shows the right information.
Thanks for any help.