Qcube/Qcodo dynamic input fields - dynamic

Does anybody have an example how can I add dynamically input fields in my qcubed project?
Thanks!

You can utilize the QPanel control to add controls on the fly. Just set its AutoRenderChildren attribute to true and set the dynamic controls parent to the QPanel.
// Instantiate our QPanel - this will render a div to contain our dynamic controls
// Note that the parent is $this. You will need to call render in your template
$this->pnl = new QPanel($this);
// Setting AutoRenderChildren so that the Panel will handle Rendering our dynamic
// controls.
$this->pnl->AutoRenderChildren = true;
// Creating a button with an Ajax action to create our dynamic controls
$this->btn = new QButton($this);
$this->btn->Text = "Add Control";
$this->btn->AddAction(new QClickEvent(), new QAjaxAction('btn_Click'));
protected function btn_Click($strFormId, $strControlId, $strParameter) {
// create the control and set its parent to the QPanel
$ctl = new QTextBox($this->pnl);
}
You can get more information on using QPanels on the QCubed examples website.
QCubed QPanel Example

Related

how to access elements not read by FlaUI using UIA2 or UIA3?

How to access/Find elements not read by FLAUI using UIA2 or UIA3?
since FLAUIInspect does not show up any of the available element under the window (while inspect.exe shows all available elements) FindAll (Children/Descendants) will not give any element.
is there a wat to get these elements using FLAUI??
First, you have to access the element you need to see. On your case, the ""pane it's a Control Type Panel inside the main window, so you gonna have to do something like this:
var automation = new UIA3Automation();
var app = FlaUI.Core.Application.Attach(application.Process.Id); //Here you can attach or start a application by path
var window = app.GetMainWindow(automation); //Get hold of the window
var allObj = window.FindAllChildren();
var panel = allObj.Where(x => x.AutomationId == "16386096").FirstOrDefault().FindAllChildren(); //Here you can use other property unique to the panel, I used the AutomationId for example
After you get hold of the panel, you can now find all the children objects.emphasized text
You need to expose the AutomationPeer for that element which is not being found by FlaUI

How to force load and item by key in form?

The case
1 - I have an accordion widget with datasource Tasks.
2. - I have a form to display info on a selected Task. It has a datasource TaskByKey.
The sought solution:
There is a button on both Tasks AccordionRow.
onClick the button should, based on the Key of the item of the AccordionRow load its data in the form with datasource TaskByKey.
What I tried:
I tried implementing the solution given as an example in Google's template, Project Tracker:
/**
* Navigates user to the specific project view page.
* #param {!string} projectKey - project key to view.
* #param {boolean=} forceReplace - optional flag that forces to replace URL
* state in cases when state push would be normally used.
*/
function gotoViewProjectPageByKey(projectKey, forceReplace) {
var params = {
projectKey: projectKey
};
gotoViewProjectPageByParams(params, forceReplace);
}
Of course the above example targets a page, where as I want to change the datasource of an element on the same page.
TLDR
How can I set the onClick event of a button to load an item by key from datasource_X to datasource_X_byKey?
Considering the fact that your TaskByKey pretends to filter only a specific task... you can put the following on the onClick event of the button.
var taskKey = widget.datasource.item._key;
var ds = app.datasources.TaskByKey;
ds.query.filters._key._equals = taskKey;
ds.load();
//Then, here you either navigate to a page or open a dialog or open a popup.
The above will work considering that your Tasks datasource and your TaskByKey datasource come from the same model.
Reference: https://developers.google.com/appmaker/scripting/api/client#Query

How to give an dynamicly loaded TreeViewItem an EventHandler?

at the moment i programm a database based Chat System.
The friendlist of every User gets loadet in a TreeView after the login.
means:
After the login I request the names of the useres friends by the following Funktion,
String namesSt[] = get.getUserFriendNameByUserID(currentUserID);
To use the given Names to load them as TreeItem into my Friendlist / TreeRootItem "rootItem"
for (int counter = 0; counter < namesSt.length; counter++) {
System.out.println(namesSt[counter]);
TreeItem<String> item = new TreeItem<String> (namesSt[counter]);
item.addEventHandler(MouseEvent.MOUSE_CLICKED,handler);
rootItem.getChildren().add(item);
}
When I now add my rootItem, I see the Names in the TreeView.
But if I click on a name, the given MouseEventHandler doesn´t get called.
Further I just want to request the text of the Element which trigger the MouseEvent, so that i can submit these name to a spezial funktion.
How can i realice such an MouseEvent?
How is it possible to call it from the dynamicly created TreeItem?
Thank you for any help :)
cheerse
Tobi
TreeItems represent the data, not the UI component. So they don't generate mouse events. You need to register the mouse listener on the TreeCell. To do this, set a cell factory on the TreeView. The cell factory is a function that creates TreeCells as they are needed. Thus this will work for dynamically added tree items too.
You will need something like this:
TreeView<String> treeView ;
// ...
treeView.setCellFactory( tv -> {
TreeCell<String> cell = new TreeCell<>();
cell.textProperty().bind(cell.itemProperty());
cell.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> {
if (! cell.isEmpty()) {
String value = cell.getItem();
TreeItem<String> treeItem = cell.getTreeItem(); // if needed
// process ...
}
});
return cell ;
}

Sitefinity get current dynamiccontent item from code

I'm currently writing a site using Sitefinity CMS. Can someone please explain how to get the current dynamic content item from server side code on page_load?
I have written a user control to display a custom gallery of sliding images. There are multiple content types in my dynamic module. The user control will sit as part of the masterpage template rather than on every page. On each page load I would like to fetch the current dynamiccontent item that is associated with the page and examine whether it has a property with the name 'Gallery'. If so I would then extract the images and render them via the usercontrol.
Thanks,
Brian.
I'm assuming your images are related content. This gets every published content item of your type.
var dynamicModuleManager = DynamicModuleManager.GetManager();
var moduleType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.YOURTYPEHERE");
var dcItems = dynamicModuleManager.GetDataItems(moduleType)
.Where(l => l.Status == ContentLifecycleStatus.Master);
foreach (var dcItem in dcItems)
{
//pass the dynamic content item to a model constructor or populate here, then
// get your image this way:
var image = dcItem.GetRelatedItems<Image>("Images").SingleOrDefault();
if (image != null)
{
ImageUrl = image.MediaUrl;
}
}

XPages: Dynamically populate Navigator Control

I need to create links of available views in database on Navigator Control. I did not find any computed formula area for that control. Just like we use code for combobox:
var v = database.getViews();
var a = []
for(var i=0; i<v.size(); i++) {
a[i] = v[i].getName()
}
return a
After achieving that, the select view will display by Dynamic View Panel of ext library.
Please guide me how to do this. Thanks in advance.
-MAK
You can create a navigation entry for each view in you database using the <xe:repeatTreeNode> in the <xe:navigator>:
<xe:navigator id="outline" expandable="true">
<xe:this.treeNodes>
<xe:repeatTreeNode loaded="true" indexVar="index" var="crrView" value="#{javascript:return database.getViews();}">
<xe:this.children>
<xe:basicLeafNode label="#{javascript:crrView.getName();}" loaded="true">
</xe:basicLeafNode>
</xe:this.children>
</xe:repeatTreeNode>
</xe:this.treeNodes>
</xe:navigator>
This code will generate a in you navigation for each view in your Database. You can use the variable crrView in the <xe:basicleafNode> to get current element of the Vector returned by database.getViews() in the loop.
You can also use other elements then the <xe:basicLeafNode> in the <xe:repeatTreeNode>.Select the RepeatNode in the NavigationItems window of the navigatior control and click on add Child.