Frage

I have a button as follows:

RadButton lnkAdd = new RadButton();
lnkAdd.ID = "BtnAdd";
lnkAdd.CommandName = RadGrid.InitInsertCommandName;
lnkAdd.Text = "Add New Record";
lnkAdd.Style.Add("display", "none");
container.Controls.Add(lnkAdd);

I want to enable it on click of a row in the grid. I have the following JavaScript to do 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(); 
    var linkButton1 = $telerik.findControl(grid.get_element(), "BtnAdd");  
    if (clientDataKeyValue == "Proposal") {
        linkButton1.set_enabled(false);
    }
    else
        linkButton1.set_enabled(true);
}

Though it reaches the linkButton1.set_enabled(true), the button is not enabled. I also tried the following to enable the button linkButton1.style.display = "block"; But this throws an error:

SCRIPT5007: Unable to set property 'display' of undefined or null reference.

Though it finds the button, style is rendered as undefined.

War es hilfreich?

Lösung

Since you have only hidden the main wrapping element of the button via its display CSS property, you should use the same thing to show it again:

linkButton1.get_element().style.display="inline-block";

Andere Tipps

Any UIControl (including RadioButtons) can be enabled and disabled using the IsEnabled property. Basically, you can just set the button to

linkButton1.IsEnabled = false;

In order to disable the button and

linkButton1.IsEnabled = true;

to reenable it. Hope that helps.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top