I have an asp page that has a Treeview on it that is populated in code behind (so not data-bound). As I expand the nodes eventually the list of item becomes so big that after the postback, I lose where I was in the tree. So I've been looking into using client-side script to use scrollIntoView but all the examples of how to get the current selected node (the node I just expanded), seem to fail for me.
var elem = document.getElementById('navTree_SelectedNode');
alert(elem.value);
For me the .value is always null, as though no item has been selected. I've tried calling this code on the window.load and also by running a script from the code-behind. So I know there are lots of posts of this is how to do it, but I can't get an ID back of the item so I can then do a document.getElementById() on to then run the scrollIntoView. Maybe I'm trying to access the value too early/late and it's not been set, so where would the best place for me to check this be?
I've also tried accessing it with:
var test = document.getElementById('navTree_Data.selectedNodeID');
and still no luck.
Just a thought, selected is the item I have just clicked on to expand, not Checked as the nodes have check boxes?
Many thanks
The issue was being caused by the .SelectAction on my nodes being set to TreeNodeSelectAction.Expand when it should be set to .SelectExpand.
Related
I have an AppMaker app that has a from based off of one address table/datasource. I can get a form with next/prev buttons, but replaced the key field (name) with a dropdown list of all names (a user can start typing names to jump there, with the dropdown showing).
My hope is that when a user selects from the dropdown, the entire form updates and the next/prev buttons work properly as well (there too many records to page thru with next/prev only). I don't have to have next/prev functionality if it complicates things too much.
Currently the dropdown is working, but I cannot get the index for the next/prev buttons set or the rest of the form to reflect the selected dropdown record.
I've tried to set the "onValueEdit" event to something like this...
var selected = widget.value;
var idx = widget.options.indexOf(selected);
console.log("Selected: "+selected+", index = "+idx+"\n");
if(idx < 0) { //...this error is never hit
console.log("Index error - setting to zero!\n");
idx = 0;
}
widget.datasource.loadPage(idx); //...update form?
Two observations via console logging:
The "idx" var is never set to the selected dropdown index reliably, and is
often "0" (tho no error msg ever shows), so the "indexOf()" function
isn't working as expected.
The "selected" var (name) is always correct.
If I call widget.datasource.loadPage(...) with a fixed value (say 5) it has no effect on what is shows in the form either (previous loaded data remains) - obviously not the way to do it :v/
Can you steer a noob in the right direction?
If you are using default App Maker form, then you can see that so-called pager, doesn't actually paginate. It triggers prevItem/nextItem datasource methods, in other words it navigates through datasource items, not pages. Here is a quote from App Maker docs:
nextItem: Selects the next item. For Query Datasources, if the current item is the last item on the page, then this loads the next page and selects the first item on the newly loaded page.
So, if you already have all your items loaded(you set query page size for your datasource to 0), then you need just to change selected item within datasource:
// onValueEdit dropdown event
// assuming, that form and dropdown share same datasource
widget.datasource.selectKey(newValue._key);
If you really have lots of items and it is not feasible to load all of them in one call... then it will be all another story...
UPDATE:
It's important that Options and Value are set as shown in the image below!
However, I had trouble setting them that way (read: wasted hours!) until I wiped them both completely using More options in the binding picklist, and tried again (I had even tried on a brand new app!). I was being forced to choose ..projections.. and then a final field before the OK button would be available.
Not sure if AppMaker is buggy here or there is something simple I'm not understanding!
None of the coding in my original question is required.
Once set this way, binding just works as you would expect it!!
All other fields are set as #datasource.item. and are bound to whatever item is chosen. No Events settings are necessary for the dropdown either, as I thought they might be.
I deleted this page and started again, and replaced the default business name data field with a drop down, I set the dropdown as:
Options: #datasources.Addresses.items
Value: #datasources.Addresses.item
It works fine?! Not sure what happend in my original page!
UPDATE:
So it seems you need to delete both the Value and Options and then re-enter these. The OK will light up when you do.
Also, my original take on App Maker was to build the UI and attach data. That was my first mistake. You build the data then have App Maker build edit/add pages for you.
On a server control I have a DevExpress ASPxClientListBox which is populated dynamically on the client. The server does not need to know anything about it but it is initialized on the server. Normally this server control does not have any problems... however, if I put it in an ASPxCallbackPanel it will work on the first page load but, after a callback, if the ListBox's client side selected index changed event is fired, the selected items values are lost and "undefined" though the keys or "texts" are intact.
On a side note... after a callback the first item in the ListBox can not be selected.... what I mean is that the first item is not highlighted on mouseover or mouseclick.
Links which are slightly relevant but not what I need:
http://www.devexpress.com/Support/Center/p/Q312536.aspx
I had another link that talked about the "unable to select first item" issue and said that it had something to do with adding the items prior to the control hierarchy being established so the solution was to add the items in the ListBox client side Init event as opposed to the page_load event. I am adding the items after the ListBox has been initialized so I don't see this as a solution ... and I can't find the link now anyways...
Edit: I just found that other link again: http://www.devexpress.com/Support/Center/p/Q367021.aspx
Part of the problem is addressed in the second link you provided. What happens is that...
...this function is called immediately when a page is loaded. However,
an ASPxListBox hierarchy is not yet ready. The correct way to call the
getList function is to handle the ASPxClientListBox event...
To cut the long story short, something like the following won't execute properly if you run it e.g. on load...
yourListbox.AddItem("Test1");
yourListbox.AddItem("Test2");
yourListbox.AddItem("Test3");
yourListbox.AddItem("Test4");
...but the following should work...
s.Properties.ClientSideEvents.Init =
#"function(s, e) { yourListbox.AddItem('Test1'); yourListbox.AddItem('Test2'); yourListbox.AddItem('Test3'); yourListbox.AddItem('Test4'); }";
I guess the first selected-items-problem could have happened for the same or similar reason.
Using devexpress xtrareports version 11.2 I have setup a databound report using a temporary table. I bind the content to a single xrrichttext on the report.
Each record is generated and each next record starts on a new page. Now I want to lose the automatic pagebreak and implement my own logic for breaking.
But I have not yet been able to drop the auto-break. I went through all the pagebreak properties in design mode but everything is already set to none.
Besides the xrrichtext there is also a xrpanel which contains a xrlabel, all are set to a low height as default with cangrow/canshrink to true.
Is there something specific I can set for this or am I still missing something?
edit:
I am using the detailband, I had given the xrrichtext a minimal height after realizing this might be the problem, but this didnot seem to help. But after I restarted this did however fix the problem.
But now my own pagebreaks are not working as expected, not sure if I should start another question for this.
In the detailband I have added a xrpagebreak.
In the detail_beforeprint I check if the current records needs a pagebreak
If GetCurrentColumnValue("break") = True Then
xrPageBreak1.Visible = True
Else
xrPageBreak1.Visible = False
End If
Only now I am getting a pagebreak for every record, doesnot seem to react on the value for field 'break'?
which reportband are you using?
some report bands only appear once on every page, usually data is added to the detail band, this is displayed until the page is full. or until you break the page yourself
This question already has an answer here:
Closed 10 years ago.
In a page inside the insert component popup window. When a user is trying to Select a component and a Template then how to *restrict them to select the same combination of component and template * that is already present in the component list.
I thought of writing a javascript on insert button.Please suggest if i am going in right way.
As Bart says above your question is amazingly vague, but here is an attempt at an answer as i've just done something similar. Given the vagueness, i'm assuming that you're knee deep in JS code and what I'm putting here will make sense to you :)
In your javascript you'll likely store the selected component presentation in a property as your user clicks on a given cp in the list, for example:
// keeps stock of the current selected component presentation
p.selectedComponentPresentation;
to use simply:
var componentPresentation = p.selectedComponentPresentation;
and to set you can see i get the tab control first, store the component presentationTab and from there call the getSelectedComponentPresentation():
var masterTabControl = $controls.getControl($("#MasterTabControl"),
"Tridion.Controls.TabControl");
p.compPresTab = masterTabControl.getPage("ComponentPresentationsTab");
p.selectedComponentPresentation
= p.compPresTab.getSelectedComponentPresentation();
Again I do hope this makes sense, I'm also assuming by now you'll know how to get the pageId
If you're in a Component popup window, you can get the ID of the Component through
$display.getItem().getId()
This will actually work in any Item edit popup (so Pages and other item types too).
It will not work in the main Dashboard view (so where you see the tree on the left and the list on the right), since there you don't have a single "current item".
You will have to update your question with information as to where your code is running, because that is unclear to me now. As far as I know there is no place in the Web GUI where you have both a "current Component" and a "current Page".
I have created a site that allows users to see a list of files that currently reside on my FTP site.
I have got the files appearing but when I select one and click download, it is not registering that I have selected an item.
At the moment I am using:
If CheckBoxList1.SelectedItem.Value = "" Then
MsgBox("A file needs to be selected...!")
End If
'NOTE - A SELECTION ISN'T BEING RECORDED BY THE PROGRAM!!'
If CheckBoxList1.SelectedItem.Value <> "" Then
I think that it is not registering the selection being made, because the item being selected is not a string value.
But I am not sure what to set this as.
It would help if you provided the actual code being used to attach the selection / change handler as well as the event method body.
I'm guessing your attaching to the checkbox SelectedIndexChanged event. If that's the case then make sure that you have actually bound a "value" to the checkbox list, ensure that you are using the "DataTextField"and "DataValueField" properties instead of just default binding the checkboxlist to a collection.