I have read in a few posts that you only maintain data in the current view for performance reasons, but is there a way to turn that off? Or is there another workaround?
Thanks
Dennis
15 Answers, 1 is accepted
Thank you for writing.
Your case requires using an unbound GridViewBooleanColumn. Unfortunately, the current version of RadGridView does not support unbound columns and there is no way to workaround this limitation.
At the moment, we are refactoring RadGridView. The unbound mode will be available in the new RadGridView once it is released next month.
If you need further assistance, please contact us.
Sincerely yours,
Georgi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Hi Doug Hamilton,
You'll find this feature and full support for unbound columns in the new version of RadGridView, which will be a part of our Q1 2008 release, due in mid-April.
Meanwhile, you could download and try Q1 2008 Beta version: http://www.telerik.com/community/forums/thread/b311D-bceebb.aspx
Best wishes,
Georgithe Telerik team
Instantly find answers to your questions at the new Telerik Support Center
As I play with checking and unchecking boxes, about every 10th try will suddenly deselect a weird range of already selected rows. There doesn't appear to be a pattern or reason of why.
Right now I'm going to try to post these changes to the database and do a rebind on each selection. I wanted to avoid this process, but need to make sure the checkboxes are correct so I have no choice.
Any idea what's going on?
Private Sub RadGrid_CellClick(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles RadGrid.CellClick
If e.ColumnIndex = 1 Then
RadGrid.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = Not RadGrid.Rows(e.RowIndex).Cells(e.ColumnIndex).Value
End If
End Sub
I have to provide a selectable interface at the click of a button, so I show or hide a value-added checkbox column. (In order to get the clicks to check the checkbox I have to trap CellClick and MouseClick and set the control when those events are triggered, so I got past that awkwardness...)
However, as soon as the grid scrolls one pixel, all the checks are cleared. I have not found any suggestions or previous conversations which point to a solution. Using any other version of Telerik is not an option at this time.
Please assist.
I am not able to assist you efficiently with the supplied information. I would kindly ask you to open a support ticket where you can enclose a sample project which demonstrates your scenario. Also, it would be great if you illustrate the exact steps that we should follow in order to replicate this behavior.
Thank you in advance for your time and cooperation.
Svett
the Telerik team
It would really be great if there were a way to bind the column for each row to the dataset column/rows, but I couldn't find how that is done in the version we are using, thus a 'brute force' method.
Two events need to be trapped to detect and visually set the check mark, depending upon whether they click in the checkbox (mouseclick) or if they click in the cell outside of the checkbox (cellclick). The RadGridView is named "mainGrid"
void mainGrid_MouseClick(object sender, MouseEventArgs e)
{
RadElement element = this.mainGrid.ElementTree.GetElementAtPoint(e.Location);
if (element is RadCheckmark && element.Parent is RadCheckBoxEditorElement)
{
GridCheckBoxCellElement checkboxCell = (GridCheckBoxCellElement)((RadCheckBoxEditorElement)element.Parent).Parent;
checkboxCell.Editor.Value = !(bool)checkboxCell.Editor.Value;
((DataView)mainGrid.DataSource).Table.Rows[((Telerik.WinControls.UI.GridCellElement)(checkboxCell)).RowIndex]["Selected"] = checkboxCell.Editor.Value;
}
}
void mainGrid_CellClick(object sender, GridViewCellEventArgs e)
{
GridCheckBoxCellElement cboxElement = (sender as GridCheckBoxCellElement);
if (sender is GridCheckBoxCellElement)
{
cboxElement.Editor.Value = !(bool)cboxElement.Editor.Value;
((DataView)mainGrid.DataSource).Table.Rows[((Telerik.WinControls.UI.GridCellElement)(cboxElement)).RowIndex]["Selected"] = cboxElement.Editor.Value;
}
}
I can send you the small project (somehow?), just in case you want to see what I was doing for the sake of providing a better solution. :)
I am glad to hear that you found a solution on your own. Nevertheless, I would kindly ask you to provide us with a sample project where the illustrated behavior occurs. RadGridView usually automatically commits the changes from the editors to its underlying data source. Hence, you do not need to perform any further actions. You can open a support ticket where you can attach your project and details about it. This will allow us to handle this case, once we are able to reproduce it.
Greetings,Svett
the Telerik team
Thank you,
If you're unable to submit a ticket, then you can always copy the code here (using the format code blocks). Forum posts do not have the same priority as support tickets, but this is the next best way I know of to submit code for review.
Hope this helps
Richard
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
using
Telerik.WinControls;
using
Telerik.WinControls.UI;
namespace
clearingCheckboxes
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
this
.Load +=
new
EventHandler(Form1_Load);
}
void
Form1_Load(
object
sender, EventArgs e)
{
mainGrid.SuspendLayout();
mainGrid.GridElement.BeginUpdate();
mainGrid.MasterGridViewTemplate.AutoGenerateColumns =
false
;
mainGrid.MasterGridViewTemplate.AllowAddNewRow =
false
;
mainGrid.MasterGridViewTemplate.AllowEditRow =
false
;
mainGrid.CellClick +=
new
GridViewCellEventHandler(mainGrid_CellClick);
mainGrid.MouseClick +=
new
MouseEventHandler(mainGrid_MouseClick);
mainGrid.CellFormatting +=
new
CellFormattingEventHandler(mainGrid_CellFormatting);
// add a checkbox for allowing selecting rows to export
GridViewCheckBoxColumn cboxcolumn =
new
GridViewCheckBoxColumn(
"Selected"
,
"Selected"
);
cboxcolumn.VisibleInColumnChooser = cboxcolumn.IsVisible =
false
;
mainGrid.MasterGridViewTemplate.Columns.Add(cboxcolumn);
// add some other columns
GridViewTextBoxColumn edtcol =
new
GridViewTextBoxColumn(
"column1"
,
"column1"
);
edtcol.TextAlignment = ContentAlignment.TopLeft;
edtcol.IsVisible =
true
;
mainGrid.MasterGridViewTemplate.Columns.Add(edtcol);
edtcol =
new
GridViewTextBoxColumn(
"column2"
,
"column2"
);
edtcol.TextAlignment = ContentAlignment.TopLeft;
edtcol.IsVisible =
true
;
mainGrid.MasterGridViewTemplate.Columns.Add(edtcol);
edtcol =
new
GridViewTextBoxColumn(
"column3"
,
"column3"
);
edtcol.TextAlignment = ContentAlignment.TopLeft;
edtcol.IsVisible =
true
;
mainGrid.MasterGridViewTemplate.Columns.Add(edtcol);
// create a datatable/dataset of data
DataSet dataSet =
new
DataSet();
System.Data.DataTable table =
new
DataTable(
"Table"
);
// Declare variables for DataColumn and DataRow objects.
DataColumn column;
DataRow row;
// Create new DataColumn, set DataType,
// ColumnName and add to DataTable.
// whether or not we have a column in the dataset makes no difference, the checkbox clears
column =
new
DataColumn();
column.DataType = System.Type.GetType(
"System.Boolean"
);
column.ColumnName =
"Selected"
;
// Add the Column to the DataColumnCollection.
table.Columns.Add(column);
column =
new
DataColumn();
column.DataType = System.Type.GetType(
"System.String"
);
column.ColumnName =
"column1"
;
column.ReadOnly =
true
;
column.Unique =
true
;
// Add the Column to the DataColumnCollection.
table.Columns.Add(column);
column =
new
DataColumn();
column.DataType = System.Type.GetType(
"System.String"
);
column.ColumnName =
"column2"
;
column.ReadOnly =
true
;
column.Unique =
true
;
// Add the Column to the DataColumnCollection.
table.Columns.Add(column);
column =
new
DataColumn();
column.DataType = System.Type.GetType(
"System.String"
);
column.ColumnName =
"column3"
;
column.ReadOnly =
true
;
column.Unique =
true
;
// Add the Column to the DataColumnCollection.
table.Columns.Add(column);
dataSet.Tables.Add(table);
for
(
int
i = 0; i <= 40; i++)
{
row = table.NewRow();
row[
"column1"
] =
"hello "
+ i;
row[
"column2"
] =
"world "
+ i;
row[
"column3"
] =
"foo "
+ i;
try
{
table.Rows.Add(row);
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
mainGrid.DataSource = dataSet.Tables[0].DefaultView;
mainGrid.ResumeLayout();
mainGrid.GridElement.EndUpdate();
}
// trapping out the editor to get value changed demonstrates that ValueChanged does not fire when the checkbox is cleared via a scroll...
void
mainGrid_CellFormatting(
object
sender, CellFormattingEventArgs e)
{
if
(sender
is
GridCheckBoxCellElement)
{
RadCheckBoxEditor editor = (RadCheckBoxEditor)((Telerik.WinControls.UI.GridDataCellElement)(e.CellElement)).Editor;
if
(editor !=
null
)
{
editor.ValueChanged +=
new
EventHandler(editor_ValueChanged);
}
}
}
void
editor_ValueChanged(
object
sender, EventArgs e)
{
int
i = 0;
}
void
mainGrid_MouseClick(
object
sender, MouseEventArgs e)
{
RadElement element =
this
.mainGrid.ElementTree.GetElementAtPoint(e.Location);
if
(element
is
RadCheckmark && element.Parent
is
RadCheckBoxEditorElement)
{
GridCheckBoxCellElement checkboxCell = (GridCheckBoxCellElement)((RadCheckBoxEditorElement)element.Parent).Parent;
checkboxCell.Editor.Value = !(
bool
)checkboxCell.Editor.Value;
((DataView)mainGrid.DataSource).Table.Rows[((Telerik.WinControls.UI.GridCellElement)(checkboxCell)).RowIndex][
"Selected"
] = checkboxCell.Editor.Value;
}
}
void
mainGrid_CellClick(
object
sender, GridViewCellEventArgs e)
{
GridCheckBoxCellElement cboxElement = (sender
as
GridCheckBoxCellElement);
if
(sender
is
GridCheckBoxCellElement)
{
cboxElement.Editor.Value = !(
bool
)cboxElement.Editor.Value;
((DataView)mainGrid.DataSource).Table.Rows[((Telerik.WinControls.UI.GridCellElement)(cboxElement)).RowIndex][
"Selected"
] = cboxElement.Editor.Value;
}
}
private
void
btnSelect_Click(
object
sender, EventArgs e)
{
mainGrid.Columns[
"Selected"
].IsVisible =
true
;
}
}
}
Thank you for writing back.
After I inspected your code, I determined that RadGridView does not allow editing of its values. Could you give us more information what you want to achieve? Why do you try to enable editing when you have explicitly disabled it? If you want to enable only editing of the check box column, you should set the ReadOnly property for the rest of the columns to false.
Off topic, please note that in order to be able to access the support ticketing system you will need to have a valid license with support subscription, or to be added as Licensed Developer to account with such license. More information regarding this matter can be found in the "Cancelling a Context Menu Click" thread, which you have previously opened (it is available in Your Telerik account). Please bear in mind that your account might be denied support services from Telerik representatives until you enable support for it.
Regards,
Svett
the Telerik team
I find no discernible linkage between your point/question and the issue, please elucidate how you see they are linked; if this is correct, then you should be able set them to read-write and remove my code which handles the checkbox column and it should work?
Or provide Telerik sanctioned methods of achieving the results (which is, at will, to display a column of checkboxes so users can select line items to export - those checks are then iterated, the corresponding rows then exported).
Concerning support. I am afraid we lack a certain level of coordination on our side and the only thing we have, as relayed previously to Nikolay, is an invoice number. I inherited this project and was/am not involved in the choosing or purchasing of Telerik controls. I can only assure you that Nikolay verified the invoice. That is as far as I can provide information for you.
In conclusion, I have worked-around the drawback. Whether or not you can find issues with the Telerik controls is merely academic at this point, I suppose.
Thank you again.
Our RadControls can be used in many different scenarios using many different settings. As we are trying to think of what might cause the issue that you describe, you are trying to exclude the possible reasons for this issue getting to the true reason. The question that my colleague Svett has asked is adequate to what you have given as information, given the fact that you are describing that you want to edit the checkboxes while at the same time your code clearly outlines that you are avoiding the editing operation. This controversial information made us confused, so this was the first question to ask in order to clear the path to the real case. I hope that you understand our position.
As to your license, as I mentioned in the other thread of yours, the invoice number that you have given is correct. Still, in order to be able to open support tickets in our ticketing system and to get further responses from Telerik representatives, you have to be added as a license developer to the purchase.
Finally, we are glad to hear that you managed to find a solution for your case. Still, we would again strongly recommend updating to the latest version at your earliest convenience, because since Q1 2010 many issues have been addressed and many new features have been introduced.
Nikolay
the Telerik team