NoPost

Hi.
I’m trying to avoid postbacks, so I created GoViewDataRenderer class and handle all requests (goRequest) from client-side. Everything works fine but I have one problem I don’t know how to deal with.
User can rescale diagram and user can move one of the node outside of current view borders. So, I have to resize GoView. When I did it using postback I did
GoViewDiagram.Height = new Unit(GoViewDiagram.DocumentSize.Height * ZoomScale);
GoViewDiagram.Width = new Unit(GoViewDiagram.DocumentSize.Width * ZoomScale);
So I changed the size of IMG element on the page.
Now I can change the size of GoView object, but the size of IMG element remains the same, so I have to change the size of IMG element manually. But I don’t know how to get the size of GoView on client-size. I found you have img variable that contains img.goView object - but it doesn’t contain height and width of GoView.
Do you have any idea how to change the size of view without postback?

You just need to set the width and height properties of that IMG element.
var img = goFindImg(‘GoViewDiagram’);
img.width = img.width * zoomscale;
img.height = img.height * zoomscale;
The value of img.goView will be a plain JavaScript object that holds all the data that has been rendered about the GoView – cursors, tooltips, menus, GoPartInfos, and various click functions.

Walter, I’m talking about more general case. Let’s say that user adds new node to my diagram. I do (on client-side) ‘goRequest’ and (on server-side) I add new node and change the height of Document. So GetWebImage.aspx returns new image and I have to know what is the size of new image (on client-side!) in order to change the size of IMG element on the page.

Oh, I think I see what you want. I haven’t tried this, but…
Try overriding GoViewDataRenderer.Render to call the base method and then append a statement to set the width and height:
public override String Render() {
String s = base.Render();
s += “if (” + GenerateViewRef() + “.img) {\n”;
s += GenerateViewRef() + ".img.width = " + desiredwidth.ToString() + “;\n”;
s += GenerateViewRef() + ".img.height = " + desiredheight.ToString() + “;\n”;
s += “}\n”;
return s;
}
where you figure out what (reasonable!) values you want to specify for the desiredwidth and desiredheight.
The generated JavaScript checks first to see if the element is known yet; I believe (but haven’t checked) that the above code when first loaded will execute before the element exists. You’ll need to debug this to see if it works at the right times.

Thank you!
That’s exactly what I needed!