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".
Related
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.
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.
I am figuring my way around Alloy (slowly !).
I would like to know if there a way we can easily destroy and remove all the UI elements with a node ? Do we have anything like ?
view.empty()
What I am trying to do is, when a tab is loaded, I want the view to insert a Label "loading ..." and should be removed after the data is ready.
Coming to my 2nd question: How do I delete a node ?
view.delete() ?
Something basic : There is always a parent child relation between the Views(nodes as you say), to delete a view you need to have a handle at its parent view.
For your first Question :
you can check This link.It will remove all child elements of a View.
For your second Question :
to delete a single view you have to do something like ParentView.remove(childView)
And yes Activity Indicator can be used to show a loader with/without message.
Hope it helps.
What you need is an Activity Indicator, here are the docs: http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.ActivityIndicator
How would I go about showing a nested resource by default when editing an entry in RailsAdmin? Currently it exists as a button that you have to click to show the contents.
I searched for this but ultimately ended using javascript to show the nested form by default. Following I have used:
setTimeout(function(){
$('#partner_api_account_attributes_field .toggler').click();
}, 100);
In rails_admin forms, nested resources are shown within a div with ID something like '#partner_api_account_attributes_field' where Partner was my model associated to ApiAccount. And ".toggler" is class name of the link that toggles the nested resource form.
I hope this helps. Thanks!
I've used JRab's example here http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/App-specific-system-menu/td-p/693... to add a header menu to my app. What I'm having trouble with is executing my functions from the header mennu. For example, my firstView is appHome.mxml. It instantiates a Canvas object that has an erase(). There is a button in appHope.mxml that executes the erase() on the Canvas instance. I'm trying move the Erase button out of my appHome.mxml and into my headerMenu.mxml but don't know how to execute the erase() on the Canvas instance. The first thing I thought to try was click="{appHome.myCanvas.erase()}" but obviously that didn't work.
I asked a similar question yesterday here: Flex executing a function on another view and I accepted the answer before I tried it. The problem is that the headermenu.mxml is not a child of appHome.mxml. They are both children of the main app.mxml. Secondly, the object that has the erase() is in a separate .as class I instantiate in appHome.mxml.
I hope I described my question well enough. Thanks n advance to anyone that can help.
Based on your description, I don't understand how my comment on the previous answer doesn't answer it.
The event from headermenu dispatches up to app; which can call the method on it's child (appHome) like this:
appHome.erase()