Show Telerik RadWindow from Server while maintaining scroll position - telerik

When displaying a RadWindow while scrolled to the bottom of the page, the window is rendered at the top the of the page and I have to scroll back up to see the window.
I'm maintaining post back scroll position by setting 'MaintainScrollPositionOnPostback':
<%# Page Language="C#" MaintainScrollPositionOnPostback="true" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
I have a RadListView where the ItemTemplate has a button in it. When that button is clicked, I display a RadWindow modal.
The problem is if I scroll to the bottom of the page and click the button, the page displays the window at the top of the page, but then scrolls back down to where user was scrolled at (due to MaintainScrollPositionOnPostback). So the window is displayed off screen until user scrolls back up
How can I show the RadWindow where the user is scrolled at on postback? (Not at top of page)
I've tried displaying RadWindow 2 different ways but both have same result
Way 1:
Window.VisibleOnPageLoad = true;
Way 2:
string script = "function f(){$find(\"" + RadWindow1.ClientID + "\").show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);

Add a timeout around show() to let the scrolling take place before you open the RadWindow. Otherwise, here is what happens:
postback returns, page is not scrolled
RadWindow shows up, centers in the current viewport
scrolling shifts so your RadWindow is not where you expect it
Here is an example:
string script = "function f(){setTimeout(function(){$find(\"" + RadWindow1.ClientID + "\").show(); },111);Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
where you can tweak the 111ms timeout I added for illustrative purposes. Using 0 as an argument may also suffice. To be honest, I don't know how long it takes for the scroll to shift.
By the way, I would create a JS function in the markup that would take the ID of the RadWIndow as an argument and call that instead, just to make the code more readable

Related

How to click at a certain location in div

I want to execute a click on a full-screen div which is underneath a (non full-screen) modal dialog. However it seems that the click event automatically targets the center of my background div, thereby touching content that's on top of that div (the modal dialog itself).
How can I specify where the click should happen?
This is the verbose output of my click command:
Element is not clickable at point (640, 436). Other element would receive the click: <label class="btn btn-default ">...
The root of problem is selenium clicks by sending mouseclick event not directly to the element but by screen coordinates. Therefore it cannot find clickable element by point (as described in verbose output).
There are two possible workaround (for your case):
1) Click by element position which not overlapped by modal dialog (applicaple for fullscreen div):
.moveToElement('.backdrop', 900, 10) // 900 is X offset
.mouseButtonClick(0)
2) Better, universal solution. By directily sending click event via injected javascript:
.execute(function(selector) {
document.querySelector(selector).click();
}, ['.backdrop'])

Enable div to scroll by keyboard without clicking

I have div element in which I am loading text, usually long text, so the div has scrollbars. I can scroll in this div with mouse, when the cursor is on it, but I cant scroll with page up and down, unless I click inside the div first. So Is there a way to avoid this clicking, to do it from code when the text is loaded?
The answer here worked for me:
Set keyboard focus to a <div>
Basically add a tabindex to the div:
<div id="mydiv" tabindex="-1">
then programmatically set the focus using:
document.getElementById("mydiv").focus();
From the original post:
The tabindex value can allow for some interesting behaviour.
If given a value of "-1", the element can't be tabbed to but focus can
be given to the element programmatically (using element.focus()).
If given a value of 0, the element can be focused via the keyboard and
falls into the tabbing flow of the document.
Values greater than 0
create a priority level with 1 being the most important.
Here it is, as you described. I appended an input to the content div, then focus() it, rather than trying to focus the div. So, immediately after pressing load text, you can press pg up/dn to scroll div.
HERE IT IS
$("div").append('<input type="text" id="focusDiv">');
/*
Here I need to have some code which gives "focus to the div, so if I press the load text and then immediately PageDown key, sthedvis scrolls down.
$("button").on("click", function (e) {
e.preventDefault();
$("div").html("Very long text...");
$("div").append('<input type="text" id="focusDiv">');
$('#focusDiv').focus();
});

dojo Show/Hide One ContentPane While Another ContentPane Is Liquid

I've been struggling for weeks trying to crack this nut so I'm not sure if it's impossible, or if it's my lack of coding chops... or both. I'm not a programmer and I'm a newbie to Dojo Toolkit.
I have a site using the BorderContainer layout. I'm trying to create an effect where I can use a button to open and close a dropdown type box that will contain controls. I need this dropdown to be hidden on page load, and then open when you click the button.
My problem is that when I open the dropdown, it pushes the content pane below it off the bottom of the browser window. I need the lower ContentPane to stay fit within the remaining space of the browser window when the dropdown opens. Additionally, I want the dropdown to sit outside of the scrollable container for the content below it, which is why I have it set up to sit outside a nested BorderContainer below it.
I've created a simplified version of the code to demonstrate my challenge (see link below). If you load the page you can see the center ContentPane scrolls the content. But, if you then click on the button, a dropdown div expands above the content. Then when you scroll, you'll notice that you can't see the full pane because it's in no-man's-land below the bottom of the browser window. I assume that because the div is set to display:none on load, it's size is not accounted for on page load. Then, when you open it by pressing the button, it's size is additive and the pane below doesn't know how to resize or account for the new element.
I've tried using the visibility attribute, but that leaves a gap for the div when it's still closed. I've tinkered with some code that controls the height that shows promise, but each of my dropdown boxes will be different sizes so I'd prefer that the height be set to "auto" rather than a specified pixel size.
Does anyone have any idea how I can accomplish this so that the lower pane will fit in the space without pushing off the screen?
Here's a sample of the page:
http://equium.com/scaffold.html
(I had some problems trying to insert the full HTML page here as a code sample so if that's a preferable way to handle it, and someone can let me know the best way to embed all of that code, I'd appreciate it.)
Thanks is advance, I'd really apprecaite anyone's feedback.
You might want to take a look at dojox.layout.ExpandoPane (though be warned I think it has only worked properly for top and left regions for a while).
Also, I'd suggest simplifying/altering your layout a bit. See example here:
http://jsfiddle.net/taFzv/
(It'd probably need some tweaking to get exactly what you want.)
The real issue you're having is probably that the BorderContainer has no idea that parts of the view resized. ExpandoPane takes care of that by telling the BorderContainer to re-layout after its animation completes.
It works under IE8.0. When dropdown box open, just keep pressing mouse from page and drag to bottom, you could see the content was pushed to out of page. It looks the browser could not detect it and could not add it to "scroll bar" account.
I would suggest taking out all BorderContainers except your top level one, the one with mainPage as the id.
Place your {stuff here} div into the mainPage BorderContainer, after the ContentPane with the Close/Open button. Make sure you make it dojotype dijit.layout.ContentPane, set up layoutpriority, and set region to top. Set the height to 0/x when clicking the Open/Close button, instead of setting display.
Try your page again. If that doesn't fix it, you probably need, a call to layout, resize, or both to indicate to the BorderContainer that it needs to evaluate all its children and size the "center" pane properly. Something like dijit.byId("mainPage").layout(); Do this any time someone presses the Close/Open button, after you have changed the height of any BorderContainer children.
Maybe the dijit.form.DropDownButton would fit your needs. When click the button a tooltip is displayed that can be filled with any content you want. Just as you specified, the dropdown tooltip is only displayed when you click the button, and it doesn't mess with the underlying layout at all. The tooltip sits "on top" of the page.

jquery layout and dynamic draggable div issue

I am using jquery layout plugin and have the following situation that I cannot find a solution. How do I make the center pane increase its size permanently by dragging the div beyond the bottom border.
I have a left pane and a center pane. I dynamically generate div
when the user clicks on the left pane. The divs are generated and
dropped on the center pane. The divs are draggable and resizable.
Everything works fine with dragging and resizing on the visible center
area. The moment I drag the div beyond the bottom, the scroll bar on
the center pane appears and it seems the center pane is extending to
accommodate the new position of the dragged div. But the moment I try
to resize the div or add another div, it jumps to the top section of
the div and resets the scrollbars. I checked the center div height in
firebug and it remains at the same height when initialized
even after dragging the new div beyond the bottom.
Here is the test page html code.
Just copy/paste entirely into a html page. On the left pane, click on the "Add new" button will add new div that is draggable and resizable.
Click on "Add new"
Drag the newly added div beyond the bottom of the center pane.
The center pane shows the scrollbar as it is suppose to.
If you check the center div's height in firebug, it is not changing
Now try resizing the newly added div by dragging its handle
It jumps to the top and the center box loses its scrollbar.
I could not paste the complete html page so here is the reference to the code at the bottom of this thread
http://groups.google.com/group/jquery-ui-layout/browse_thread/thread/ca922aa44c0048ee
And here is the test link http://jsfiddle.net/yZc63/
I am surprised no one has come across this situation before? Even without the layout plugin, my solution is not very pretty. In order to simulate the page without the layout plugin, I had to keep the top and the left pane using position:fixed property in css. And there is no center div at all. I add the new div directly to the body of the html. The reason is I don't want to see additional scrollbars on top the browser scrollbars. In other words the center pane should scroll when the browser scrollbars are moved. I am attaching the solution so you have an idea.
I am open to any solution even without the layout plugin if i can simulate the previous attached file using any other approach. i am attaching my page without the layout plugin but am not sure if that is the only elegant solution left.
You can check the solution here http://jsfiddle.net/c7wrT/
Is adding the dynamic div directly to the html body a good approach?
I ran into same situation and this answer helped.
https://stackoverflow.com/a/33004821/2139859. Updated Fiddle: http://jsfiddle.net/bababalcksheep/yZc63/11/
$(".removalbe-recom").draggable({
appendTo: "body",
helper: "clone",
revert: "invalid",
cursor: "move",
containment: "document",
zIndex: 10000,
scroll:false,
start: function (event, ui) {
$(this).hide();
},
stop: function (event, ui) {
$(this).show();
}
});

Slickgrid autoscrolling window on grid click

When enableCellNavigation is enabled, the initial click and double-click on my grid immediately scrolls the page down so that the clicked row is at the top of the screen. This is quite annoying since it is not expected. Is there some way to turn this off? If enableCellNavigation is disabled, rows cannot be selected so this is not an option.
You are looking for focusOnCurrentCell()
In my case grid was scrolling to the end horizontally when clicked.
Commenting the focusOnCurrentCell() inside the function setSelectedCell(newCell,editMode) solved my problem.

Resources