I have a RadGrid which is always 5 rows of data.
I want to edit each cell. I accept the changes when the whole page is saved.
I want a test script to to test the Save Button so I need to edit the radgrid contents. I have taken my code from your sample in the forum
My test code is (Note macros to find the elements/cells):
The line "HtmlInputText inputBox = cellToEdit.Find.ByTagIndex<HtmlInputText>("input", 0);" returns a null value.
How do I get hold of the cell details so that I can edit the vale?
I want to edit each cell. I accept the changes when the whole page is saved.
I want a test script to to test the Save Button so I need to edit the radgrid contents. I have taken my code from your sample in the forum
My test code is (Note macros to find the elements/cells):
The line "HtmlInputText inputBox = cellToEdit.Find.ByTagIndex<HtmlInputText>("input", 0);" returns a null value.
How do I get hold of the cell details so that I can edit the vale?
private
void
ChangeLocationDetails()
{
RadGrid bumpGrid = Find.ById<RadGrid>(BUMP_LOCATION_GRID);
GridTableView masterTable = bumpGrid.MasterTable;
int
[] cellList = { BUMP_LOCATION_XPOSITION_CELL, BUMP_LOCATION_YPOSITION_CELL, BUMP_LOCATION_BZ_CELL, BUMP_LOCATION_FIELD_OF_VIEW_CELL, BUMP_LOCATION_PHI_CELL, BUMP_LOCATION_THETA_CELL };
for
(
int
i = 0; i < masterTable.DataItems.Count; i++)
{
float
seed = 0.01F;
foreach
(
int
j
in
cellList)
{
HtmlTableRow rowToEdit = bumpGrid.MasterTable.Rows[i];
// Locate the cell to be updated
HtmlTableCell cellToEdit = bumpGrid.MasterTable.Rows[i].Cells[j];
// Put the cell in edit mode by a mouse click
cellToEdit.MouseClick(MouseClickType.LeftDoubleClick);
m_Logger.Debug(
"TestBasicSetupRecipe:ChangeLocationDetails:bumpGrid.MasterTable.EditedItems.Count="
+ bumpGrid.MasterTable.EditedItems.Count.ToString());
// Locate the <input> element that is added when the cell enters edit mode
HtmlInputText inputBox = cellToEdit.Find.ByTagIndex<HtmlInputText>(
"input"
, 0); //<== This returns NULL
// Give it a new value
Actions.SetText(inputBox, (i + seed).ToString());
seed += 0.1F;
}
}
}
<
telerik:RadGrid
ID
=
"BumpLocationGrid"
runat
=
"server"
AutoGenerateColumns
=
"False"
AllowAutomaticUpdates
=
"True"
OnBatchEditCommand
=
"BumpLocationGrid_BatchEditCommand"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
EditMode
=
"Batch"
BatchEditingSettings-EditType
=
"Row"
BatchEditingSettings-OpenEditingEvent
=
"Click"
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"False"
/>
<
RowIndicatorColumn
Visible
=
"False"
>
</
RowIndicatorColumn
>
<
Columns
>
<
telerik:GridNumericColumn
DecimalDigits
=
"0"
HeaderText
=
"Index"
UniqueName
=
"GUIIndex"
DataField
=
"GUIIndex"
DataType
=
"System.Int32"
Visible
=
"false"
>
<
ColumnValidationSettings
>
<
ModelErrorMessage
Text
=
""
/>
</
ColumnValidationSettings
>
</
telerik:GridNumericColumn
>
<
telerik:GridNumericColumn
DecimalDigits
=
"2"
FilterControlAltText
=
"Filter XPosition column"
HeaderText
=
"X Position (mm)"
UniqueName
=
"XPosition"
DataField
=
"x_coord"
DataType
=
"System.Double"
>
<
ColumnValidationSettings
>
<
ModelErrorMessage
Text
=
""
/>
</
ColumnValidationSettings
>
</
telerik:GridNumericColumn
>
<
telerik:GridNumericColumn
DecimalDigits
=
"2"
FilterControlAltText
=
"Filter YPosition column"
HeaderText
=
"Y Position (mm)"
UniqueName
=
"YPosition"
DataField
=
"y_coord"
DataType
=
"System.Double"
>
<
ColumnValidationSettings
>
<
ModelErrorMessage
Text
=
""
/>
</
ColumnValidationSettings
>
</
telerik:GridNumericColumn
>
<
telerik:GridNumericColumn
DecimalDigits
=
"2"
FilterControlAltText
=
"Filter Bz column"
HeaderText
=
"Bz"
UniqueName
=
"Bz"
DataField
=
"bz"
DataType
=
"System.Double"
>
<
ColumnValidationSettings
>
<
ModelErrorMessage
Text
=
""
/>
</
ColumnValidationSettings
>
</
telerik:GridNumericColumn
>
<
telerik:GridNumericColumn
DecimalDigits
=
"3"
FilterControlAltText
=
"Filter FOV column"
HeaderText
=
"Field Of View"
UniqueName
=
"FOV"
DataField
=
"field_of_view"
DataType
=
"System.Double"
>
<
ColumnValidationSettings
>
<
ModelErrorMessage
Text
=
""
/>
</
ColumnValidationSettings
>
</
telerik:GridNumericColumn
>
<
telerik:GridNumericColumn
DecimalDigits
=
"2"
FilterControlAltText
=
"Filter Phi column"
HeaderText
=
"Phi"
UniqueName
=
"Phi"
DataField
=
"phi"
DataType
=
"System.Double"
>
<
ColumnValidationSettings
>
<
ModelErrorMessage
Text
=
""
/>
</
ColumnValidationSettings
>
</
telerik:GridNumericColumn
>
<
telerik:GridNumericColumn
DecimalDigits
=
"2"
FilterControlAltText
=
"Filter Theta column"
HeaderText
=
"Theta"
UniqueName
=
"Theta"
DataField
=
"theta"
DataType
=
"System.Double"
>
<
ColumnValidationSettings
>
<
ModelErrorMessage
Text
=
""
/>
</
ColumnValidationSettings
>
</
telerik:GridNumericColumn
>
</
Columns
>
<
BatchEditingSettings
EditType
=
"Row"
></
BatchEditingSettings
>
</
MasterTableView
>
</
telerik:RadGrid
>