
I am having a radgrid and a server button outside the radgrid.
In dotnet grid and button I can able to access the grid rows from button client side click.
Is it possible in Telerik ?
If so please provide me some example code.
Regards
Sreedhar A
8 Answers, 1 is accepted

var grid = window["<%= gvWorkingHours_New.ClientID %>"];
Now grid.MasterTableView is not coming as null
But if I am using this
var grid = $find('<%= gvWorkingHours_New.ClientID %>').get_masterTableView();
it is coming as null.
We are using older version of Telerik. ie 2008
I cannot upgrade to Telerik 2009. Product is already in live.
I want to access all rows and cells of the grid in javascript
Can you please tell me the next steps of this
var grid = window["<%= gvWorkingHours_New.ClientID %>"];
grid.MasterTableView
.....
Please send me some code.
Thanks
Sreedhar

Hi
I am having a radgrid. It is having one templatecolumn . I assigned a uniquename for that gridtemplate column.
I am having a button outside the grid
On clientclick of that button I am accessing all the rows of the grid.
I could able to read all the rows but in the cellID.innerHTML I am getting
"<INPUT class=inputsNoExpression id=ctl00_Cont_gvWorkingHours_New_ctl01_ctl04_txtSlotName value=Sree name=ctl00$Cont$gvWorkingHours_New$ctl01$ctl04$txtSlotName> "
My value is Sree
How to get that?
Please give the code snippet for accessing the gridtemplate cell value.
My Code:
<asp:Content ID="content" runat="server" ContentPlaceHolderID="Cont">
function AddSlot_New()
{
debugger;
var grid = window["<%= gvWorkingHours_New.ClientID %>"];
for (var i = 0; i < grid.MasterTableView.Rows.length; i++)
{
var row = grid.MasterTableView.Rows[i];
var cellID = grid.MasterTableView.GetCellByColumnUniqueName(row, "txtSlotName");
alert(cellID.innerHTML);
}
}
<rad:RadGrid ID="gvWorkingHours_New" runat="server" Skin="Default" AutoGenerateColumns="false"
OnNeedDataSource="gvWorkingHours_New_NeedDataSource" OnItemDeleted="gvWorkingHours_New_ItemDeleted">
<ClientSettings>
<Selecting AllowRowSelect="true" />
</ClientSettings>
<MasterTableView>
<Columns>
<rad:GridTemplateColumn UniqueName="txtSlotName">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtSlotName" CssClass="inputsNoExpression" Text='<%# Bind("SlotName") %>'></asp:TextBox>
</ItemTemplate>
</rad:GridTemplateColumn>
</Columns>
</MasterTableView>
</rad:RadGrid>
<asp:Button ID="LinkButton1" runat="server" width="97px" CssClass="sf-inputsLinkButton" OnClientClick="return AddSlot_New()" OnClick="LinkButton1_Click"/>
</asp:Content>
Regards
Sreedhar Ambati

Please let me know how do i achieve this.
Thanks in Advance
Vivek

Attach CommandName to the GridButtonColumn and in ItemCommand event, check with the CommandName and can access the corresponding cell value.
ASPX:
<
telerik:GridButtonColumn
CommandName
=
"Click"
Text
=
"Click"
></
telerik:GridButtonColumn
>
C#:
protected
void
RadGrid1_ItemCommand(
object
source, GridCommandEventArgs e)
{
if
(e.CommandName ==
"Click"
)
{
GridDataItem item = (GridDataItem)e.Item;
string
v = item[
"ColumnUniqueName"
].Text;
}
}
Thanks,
Princy.

Hey Princy,
Thanx .. It works!

Need one more favor from your side.
I need to create a search page. There are several search criteria. Once i filled the first criteria, there should be button for NEXT to fill next criteria. It looks likes a grid where criteria are inside the grid and simple paging is there for NEXT and PREVIOUS.
Could you please suggest me how do i take list controls and dropdowns inside the grid .How do i appear new controls after clicking NEXT or you will suggest new approach ?
Thanks in advance.
It will be way more simple if you just use one RadListBox1 and two buttons. On these buttons click you can change the datasource of your RadListBox.
For example, if your asp page look like:
<
telerik:RadListBox
ID
=
"RadListBox1"
runat
=
"server"
/>
<
asp:Button
ID
=
"Button2"
runat
=
"server"
Text
=
"Prev"
OnClick
=
"Button2_Click"
/>
<
asp:Button
ID
=
"Button1"
runat
=
"server"
Text
=
"Next"
OnClick
=
"Button1_Click"
/>
This will be the pseudocode for the code-behind:
protected
void
Button1_Click(
object
sender, EventArgs e)
{
string
selectedValue = RadListBox1.SelectedItem.Value;
Session[
"criteriaNumber"
] = (Session[
"criteriaNumber"
]
as
int
) + 1;
(Session[
"criteriaSelecteds"
]
as
List<
string
>).Add(selectedValue);
RadListBox1.DataSource =
new
YourDataSource(Session[
"criteriaNumber"
], selectedValue);
RadListBox1.DataBind();
}
protected
void
Button2_Click(
object
sender, EventArgs e)
{
int
num = Session[
"criteriaNumber"
]
as
int
;
Session[
"criteriaNumber"
] = num - 1;
(Session[
"criteriaSelecteds"
]
as
List<
string
>).RemoveAt(num);
string
selectedValue = (Session[
"criteriaSelecteds"
]
as
List<
string
>)[num - 1];
RadListBox1.DataSource =
new
YourDataSource(num - 1, selectedValue);
RadListBox1.DataBind();
}
The above pseudocode only illustrates how you can achieve similar functionality. You will have to implement it depending on your exact scenario.
Regards,
Vasil
the Telerik team