In my Radgrid CommandItemTemplate, I have a bunch of buttons. Some buttons are hidden to start with and based on the row clicked, they are visible or remain hidden.
I tried the following while adding buttons, which successfully hides the button.
public class MyTemplate : ITemplate
{
protected RadButton lnkAdd;
public void InstantiateIn(System.Web.UI.Control container)
{
lnkAdd = new RadButton();
lnkAdd.ID = "BtnAdd";
lnkAdd.CommandName = RadGrid.InitInsertCommandName;
lnkAdd.Text = "Add New Record";
container.Controls.Add(lnkAdd);
lnkAdd = new RadButton();
lnkAdd.ID = "BtnEdit";
lnkAdd.Text = "Edit";
container.Controls.Add(lnkAdd);
container.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "hideButtons",
"\n<script type=\"text/javascript\">"
//+ "\n$(function(){"
+ "\n$(document).ready(function ruchi(){"
+ "\n $(\"#" + lnkAdd.ClientID + "\").hide(); "
+ "\n return false;"
+ "\n });"
+ "\n</script>"
);
}
}
OnRowSelected I have this:
But it fails to show the button. Please let me know how can I achieve this.
Also is there a way the the commandItemTemplate is hidden by default and added only on click of a row?
I tried the following while adding buttons, which successfully hides the button.
{
protected RadButton lnkAdd;
public void InstantiateIn(System.Web.UI.Control container)
{
lnkAdd = new RadButton();
lnkAdd.ID = "BtnAdd";
lnkAdd.CommandName = RadGrid.InitInsertCommandName;
lnkAdd.Text = "Add New Record";
container.Controls.Add(lnkAdd);
lnkAdd = new RadButton();
lnkAdd.ID = "BtnEdit";
lnkAdd.Text = "Edit";
container.Controls.Add(lnkAdd);
container.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "hideButtons",
"\n<script type=\"text/javascript\">"
//+ "\n$(function(){"
+ "\n$(document).ready(function ruchi(){"
+ "\n $(\"#" + lnkAdd.ClientID + "\").hide(); "
+ "\n return false;"
+ "\n });"
+ "\n</script>"
);
}
}
OnRowSelected I have this:
function OnRowSelected(sender, args) {
var clientDataKeyName = args.get_tableView().get_clientDataKeyNames()[0];
var clientDataKeyValue = args.get_tableView().get_selectedItems()[0].getDataKeyValue(clientDataKeyName);
var grid = args.get_tableView();
linkButton1 = $telerik.findControl(grid.get_element(), "BtnProposal");
if (clientDataKeyValue == "Proposal")
{
linkButton1.set_enabled(false);
}
else
linkButton1.set_enabled(true);
}
Also is there a way the the commandItemTemplate is hidden by default and added only on click of a row?