I am migrating an application from another company's control which selects an item in javascript under certain conditions. I can't seem to select a row.
var grid = $find("<%=rgItems.ClientID%>").get_masterTableView();
for(i=0;i<rowCount;i++) // rowCount set from hidden variable
{
if (something is true)
{
grid.selectItem(i); // doesn't work
}
}
var grid = $find("<%=rgItems.ClientID%>").get_masterTableView();
for(i=0;i<rowCount;i++) // rowCount set from hidden variable
{
if (something is true)
{
grid.selectItem(i); // doesn't work
}
}
7 Answers, 1 is accepted
0
Hello Marianne,
You can use set_selected() method to select/deselect a row on the client. It takes a single Boolean argument, specifying whether the items should be selected or not.
Kind regards,
Pavlina
the Telerik team
You can use set_selected() method to select/deselect a row on the client. It takes a single Boolean argument, specifying whether the items should be selected or not.
Kind regards,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Elliott
Top achievements
Rank 2
answered on 14 Jan 2011, 07:07 PM
<telerik:RadCodeBlock ID=
"rcBlock"
runat=
"server"
>
<script type=
"text/javascript"
>
function
check_sample()
{
var
re =
new
RegExp(
'((\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(\s*$|(\s*;\s*)))+)$'
);
var
rowCount = document.form1.txtSuppCount.value;
var
grid = $find(
"<%=rgItems.ClientID%>"
).get_masterTableView();
for
(i=0;i<rowCount;i++)
{
var
row = grid.get_dataItems()[i];
cell = row.get_cell(
"Sampling"
);
if
(cell.childNodes[0].checked==
true
)
{
var
cell = row.get_cell(
"Email"
);
var
strEmail = trim(cell.childNodes[0].value);
if
(strEmail.length == 0)
{
cell = row.get_cell(
"SupplierName"
);
alert(
'Please enter/verify the E-Mail ID of the Supplier.'
);
row.set_selected(
true
);
return
false
;
}
}
}
return
true
;
}
function
trim(s)
{
var
l=0;
var
r=s.length -1;
while
(l < s.length && s[l] ==
' '
)
{ l++; }
while
(r > l && s[r] ==
' '
)
{ r-=1; }
return
s.substring(l, r+1);
}
</script>
</telerik:RadCodeBlock>
telerik:RadGrid
ID
=
"rgItems"
Height
=
"236px"
Width
=
"95%"
runat
=
"server"
>
<
MasterTableView
DataKeyNames
=
"ID"
AutoGenerateColumns
=
"False"
>
<
HeaderStyle
BorderColor
=
"#ACA899"
BorderStyle
=
"Solid"
BorderWidth
=
"1px"
Font-Bold
=
"True"
Font-Size
=
"Small"
Height
=
"20px"
/>
<
AlternatingItemStyle
BackColor
=
"whiteSmoke"
/>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"ID"
UniqueName
=
"ID"
Visible
=
"False"
/>
<
telerik:GridBoundColumn
HeaderText
=
"Supp_ID"
DataField
=
"SupplierID"
UniqueName
=
"SupplierID"
Visible
=
"False"
/>
<
telerik:GridBoundColumn
HeaderText
=
"Supplier Name"
DataField
=
"Name"
ReadOnly
=
"True"
UniqueName
=
"SupplierName"
/>
<
telerik:GridBoundColumn
HeaderText
=
"Booth Size"
DataField
=
"Booth_Group_No"
ReadOnly
=
"True"
UniqueName
=
"BoothInfo"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"Sampling"
HeaderText
=
"Sampling"
>
<
ItemTemplate
>
<
asp:RadioButton
ID
=
"rdbYes"
runat
=
"server"
GroupName
=
"YesNo"
Text
=
"Yes"
/>
<
asp:RadioButton
ID
=
"rdbNo"
runat
=
"server"
GroupName
=
"YesNo"
Checked
=
"True"
Text
=
"No"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Supp. E-Mail ID"
UniqueName
=
"Email"
>
<
ItemTemplate
>
<
asp:TextBox
ID
=
"txtEmail"
runat
=
"server"
Width
=
"90%"
></
asp:TextBox
>
<
asp:RegularExpressionValidator
ID
=
"RegularExpressionValidator1"
ControlToValidate
=
"txtEmail"
ErrorMessage
=
"Email. "
ValidationExpression
=
"((\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(\s*$|(\s*;\s*)))+)$"
Font-Names
=
"Arial"
runat
=
"server"
ForeColor
=
"Red"
Font-Bold
=
"True"
>
I
</
asp:RegularExpressionValidator
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Line: 1902
Error: 'this._owner._owner._selection' is null or not an object
which debugging let to the line below:
if(!this._owner._owner._selection._selectRowInternal(this.get_element(),a,true,true,true)){return;
}
this._selected=b;
0
Hello Marianne,
You need to iterate through the gridItems in client and access corresponding cell text "cell.innerHTML" property. Then use the set_selected() method of griditem to select the corresponding row.
The following documentation will help you in accessing the cell value from client side:
Getting cell values for selected rows client side
Greetings,
Pavlina
the Telerik team
You need to iterate through the gridItems in client and access corresponding cell text "cell.innerHTML" property. Then use the set_selected() method of griditem to select the corresponding row.
The following documentation will help you in accessing the cell value from client side:
Getting cell values for selected rows client side
Greetings,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

Elliott
Top achievements
Rank 2
answered on 17 Jan 2011, 03:09 PM
I'll make the change but that isn't where the function is throwing an exception
the exception is being thrown on the set_selected() statement
the exception is being thrown on the set_selected() statement
0

Elliott
Top achievements
Rank 2
answered on 17 Jan 2011, 05:07 PM
I changed the textbox to a RADTextbox
now I can't even get to the value in the textbox
I can do it on the server but that defeats the purpose
the updated grid and
the function as it is now
now I can't even get to the value in the textbox
I can do it on the server but that defeats the purpose
the updated grid and
the function as it is now
<telerik:RadGrid ID=
"rgItems"
Height=
"236px"
Width=
"95%"
runat=
"server"
>
<MasterTableView DataKeyNames=
"ID"
AutoGenerateColumns=
"False"
>
<HeaderStyle BorderColor=
"#ACA899"
BorderStyle=
"Solid"
BorderWidth=
"1px"
Font-Bold=
"True"
Font-Size=
"Small"
Height=
"20px"
/>
<AlternatingItemStyle BackColor=
"whiteSmoke"
/>
<Columns>
<telerik:GridBoundColumn DataField=
"ID"
UniqueName=
"ID"
Visible=
"False"
/>
<telerik:GridBoundColumn HeaderText=
"Supp_ID"
DataField=
"SupplierID"
UniqueName=
"SupplierID"
Visible=
"False"
/>
<telerik:GridBoundColumn HeaderText=
"Supplier Name"
DataField=
"Name"
ReadOnly=
"True"
UniqueName=
"SupplierName"
/>
<telerik:GridBoundColumn HeaderText=
"Booth Size"
DataField=
"Booth_Group_No"
ReadOnly=
"True"
UniqueName=
"BoothInfo"
/>
<telerik:GridTemplateColumn UniqueName=
"Sampling"
HeaderText=
"Sampling"
>
<ItemTemplate>
<asp:RadioButton ID=
"rdbYes"
runat=
"server"
GroupName=
"YesNo"
Text=
"Yes"
/>
<asp:RadioButton ID=
"rdbNo"
runat=
"server"
GroupName=
"YesNo"
Text=
"No"
/>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText=
"Supp. E-Mail ID"
UniqueName=
"Email"
>
<ItemTemplate>
<telerik:RadTextBox ID=
"rtbEmail"
runat=
"server"
Width=
"90%"
>
</telerik:RadTextBox>
<asp:RegularExpressionValidator ID=
"RegularExpressionValidator1"
ControlToValidate=
"rtbEmail"
ErrorMessage=
"Email. "
ValidationExpression=
"((\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(\s*$|(\s*;\s*)))+)$"
Font-Names=
"Arial"
runat=
"server"
ForeColor=
"Red"
Font-Bold=
"True"
>
I
</asp:RegularExpressionValidator>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
function
check_sample()
{
var
re =
new
RegExp(
'((\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(\s*$|(\s*;\s*)))+)$'
);
var
rowCount = document.form1.txtSuppCount.value;
// var grid = ISGetObject("wgItems");
var
grid = $find(
"<%=rgItems.ClientID%>"
).get_masterTableView();
for
(i=0;i<rowCount;i++)
{
var
row = grid.get_dataItems()[i];
cell = row.get_cell(
"Sampling"
);
if
(cell.childNodes[0].checked==
true
)
// this statement works
{
var
cell2 = row.get_cell(
"Email"
);
var
rtbEmail = cell2.childNodes[0];
// how do I get to the rtbEmail control?
var
strEmail = trim(rtbEmail.get_value());
if
(strEmail.length == 0)
{
cell3 = row.get_cell(
"SupplierName"
);
// superfluous
alert(
'Please enter/verify the E-Mail ID of the Supplier.'
);
grid.selectItem(row.get_element());
return
false
;
}
}
}
return
true
;
}
0

Princy
Top achievements
Rank 2
answered on 18 Jan 2011, 08:46 AM
Hello Marianne,
Try to set Selecting-AllowRowSelect="true" of Radgrid ClientSettings and see whether this eliminates the error.
ASPX:
Thanks,
Princy.
Try to set Selecting-AllowRowSelect="true" of Radgrid ClientSettings and see whether this eliminates the error.
ASPX:
<
telerik:RadGrid
ID
=
"rgItems"
Height
=
"236px"
Width
=
"95%"
runat
=
"server"
>
<
MasterTableView
DataKeyNames
=
"ID"
AutoGenerateColumns
=
"False"
>
<
Columns
>
. . . . . . . .
</
Columns
>
</
MasterTableView
>
<
ClientSettings
Selecting-AllowRowSelect
=
"true"
>
</
ClientSettings
>
</
telerik:RadGrid
>
Thanks,
Princy.
0

Elliott
Top achievements
Rank 2
answered on 18 Jan 2011, 02:36 PM
Princy - you're a prince
yes, that was the problem
yes, that was the problem