I am currently evalulating the UltraWebGrid for my company and I have run into a problem that should be easy (I hope). I have added the grid to my asp.net form and I want to reference it in javascript in order to handle the resize. I read several posts here on how to do this and specifically in the help it mentions to get a reference you do this:
var grid = igtbl_getGridById("UltraWebGrid1");
However, when I hit this line of code, I get the "Object expected" error. It seems as if the javascript containing this function is not getting imported somehow. However, it seems to work when I run the samples browser, so there must be something I am missing in my application.
Is there something in web.config or declarations section that I need that is not mentioned in the help or in the samples browser?
Thanks,
Tom
tom4336 said:- My grid is on a separate (virtual) tab (really just a hidden panel), so perhaps it is not getting initialized properly.
This sounds fairly likely to be your casue. How are you hiding the panel?
If you're setting its CSS to "display:none" or "display:hidden" then I would expect this to work.
If you're setting the panel's Visible property to false, however, neither it nor its contents (including your grid) will be rendered to the HTML of the page. This would prevent the grid from registering its required JavaScript files, which could cause this problem since the utility function wouldn't be found. Even if the utility function were available, your grid would essentially not exist, as far as the client is concerned.
So the second time it actually works.. if you get 'undefined' it is because the grid's ClientID is different to the server's ID, and that's what Vince answereres in some previous post. To find the control you can use igtbl_getGridByID(''<%=yourGrid.ClientID%>).
For the first problem my new guess is as you said, probably the grid's not being instanciated properly the first time. For the second, where you get undefined, I'm pretty sure you'll get it to work with the ClientID. SO now it's up to see what's going wrong the first round.
I also was thinking of trying on a new page and see what happens - and guess what it is working on the new page with only the grid on it (and some code-behind to populate it).
But ideally I'd like to get it working on my main page, but perhaps I won't be able to? The page I am trying to get it to work on is a very large page that has been migrated over the years from asp to asp.net. First I thought maybe I was missing the ig_common virtual directory, but it is there with all the files, then I thought perhaps I had to manually specify Javascriptfilename and javascriptfilenamecommon, but this did not make a difference either.
So what I have noticed on my page is this
var grid = igtbl_getGridById("SearchResultsGrid");
Fails with object expected and I can't hover over the igtbl
- 2nd time, my tab is being displayed and the grid is populated with data. This time it actually goes into the function but returns "undefined". I checked the ClientID and it is also "SearchResultsGrid".
So it seems as though I'm getting closer, but maybe the correct thing for me to do is to redirect hits on my tab to a new page with the grid in it, this would not be ideal but at least it would work.
I guess this set of javascript functions is rendered to the page whenever a grid control is added to the page. My guess is that something went wrong when you added your webgrid, so what I'd try is to delete/re-drag the control to see if it works. If your grid has already so customized, then drag&drop another grid just to see how it goes.
Please let us know what's on.
It's just on a plain-ole asp.net page. The problem isn't that it can't find the WebGrid, rather, that it doesn't know about the function igtbl_getGridById. I can F11 into the javascript for this function in the samples browser, but not in my own (I'm using VS2008 .net 3.5). So it's not even at the point yet where it's trying to find what I'm passing in.