This is a migrated thread and some comments may be shown as answers.

scrollArea.style.height cannot be set

2 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Wilson
Top achievements
Rank 1
Wilson asked on 07 Aug 2008, 08:06 PM
Hi,

I'm newbie in RadGrid.  I'm trying to implement the "Resizing grid with scrolling when data is less than scroll height" by following the RadControls document.
My version is Q2 2008.

The following taken from document :
<script type="text/javascript">
 
function GridCreated(sender, args)
 {
    var scrollArea = sender.GridDataDiv;
    var dataHeight = sender.get_masterTableView().get_element().clientHeight;
    if(dataHeight
< 350)
    {
       scrollArea.style.
height = dataHeight + 17 + "px";
    }
 }


However, it stopped at
 
scrollArea.style.height = dataHeight + 17 + "px";
with error" Object expected".

It seems
scrollArea.style.height expects an object as input rather than a string.

Please advise,
Wilson

2 Answers, 1 is accepted

Sort by
0
Wilson
Top achievements
Rank 1
answered on 07 Aug 2008, 09:45 PM
Hi,

Actually, the problem is occurred if I injected the script block in code-behind.

Dim script as string = "function GridCreated(sender, args)" + vbCrLf + _
                                "{" + vbCrLf + _
                                    "var scrollArea = sender.GridDataDiv;" + vbCrLf + _
                                    " alert(scrollArea.style.height);" + vbCrLf + _
                                    "var dataHeight = sender.get_masterTableView().get_element().clientHeight;" + vbCrLf + _
                                    " alert(dataHeight);" + vbCrLf + _
                                    "If (dataHeight < " + sScrollHeight + ")" + vbCrLf + _
                                    "{" + vbCrLf + _
                                        "scrollArea.style.height=dataHeight + 17 + ""px""; " + vbCrLf + _
                                    " }" + vbCrLf + _
                                    "}"

 ScriptManager.RegisterClientScriptBlock(Me, GetType(Page), "GridCreated", script, True)


As I cannot hardcode it in aspx page,  would u please advise any possible way to implement it.

Thanks,
Wilson
0
Wilson
Top achievements
Rank 1
answered on 08 Aug 2008, 09:18 PM
Hi,

I figured out the problem.  It was caused by copy and paste action.
VS changed "if" to "If" automatically.

Cheers,
Wilson 
Tags
Grid
Asked by
Wilson
Top achievements
Rank 1
Answers by
Wilson
Top achievements
Rank 1
Share this question
or