Reputation: 5232
On my web page is a large table and a checkbox. Initially, the table is not shown. When the checkbox is checked, the javascript calls tablename.SetVisible(cb.GetChecked())
. This fails because the invisible table is simply not on the page and cannot be made visible. The debugger says:
Microsoft JScript runtime error: 'tablename' is undefined
If I set the table to be visible, then run the web page, the checkbox works nicely and is able to make the table invisible and visible again.
But the table is really big and generally annoyable, so how do I get the checkbox to work with the table initially invisible?
In fact, this is with DevExpress controls, but I feel that this is not a DevExpress issue.
Server side source is just:
protected void Page_Load(object sender, EventArgs e)
{
gridResults.DataSource = ds.Tables["Results"];
gridResults.KeyFieldName = "Sample_Name";
gridResults.DataBind();
gridResults.SettingsPager.PageSize = 100;
}
Upvotes: 0
Views: 1155
Reputation: 20364
If you are doing this on the client side (e.g. in the browsers), if your table is not on the page, then you wont be able to do anything with it.
I would suggest that if you don't want to display the table on the page, then you set it's display
style property to none
;
C#:
gridResults.CssClass = "hidden";
CSS
.hidden{ display: none; }
Then when you change the status of the checkbox, you just toggle the hidden
class.
JavaScript
document.getElementById('[gridResults_ID]').className = ""; // show the table
OR
document.getElementById('[gridResults_ID]').className = "hidden"; // hide the table again
Upvotes: 1