The default behavior of the Flex datagrid descending sort is that a selected row remains in view, meaning that the view will scroll down to show the selected row. I would like to change this so that when doing a descending sort the veiw remains at the top, with the selected row staying in the same position with a different row. I have tried different variations with this code but cant' get it to work:
var index:int = new int(myDG.selectedIndex);
var vertPos:int = myDG.grid.verticalScrollPosition;
myDG.selectedIndex = index;
myDG.grid.verticalScrollPosition = vertPos;
Thanks for your help. I am just beginning with Flex.
What you could try is the following:
Lets define newIndex as the desired index you want your datagrid to navigate to.
You could try something like this:
dgInstance.scrollToIndex(newIndex);
dgInstance.selectedIndex = newIndex;
The thing is that I didn't test the code so it might be necessary to add a:
dgInstance.validateNow();
Related
I've been able to set the options on an AppMaker DropDown by doing this sort of thing:
google.script.run
.withSuccessHandler(function(oA){app.pages.Notes.descendants.Dropdown1.options=oA;})
.getSelectOptions();//oA is just an array
But I'd like to know how to do load different values in the options and value like we can do it in javascript with something like this:
function updateSelect(vA){
var select = document.getElementById("sel1");
select.options.length = 0;
for(var i=0;i<vA.length;i++)
{
select.options[i] = new Option(vA[i].option,vA[i].value);
}
}
And I tried this by trying to get a hold of the dom element as follows:
var elem=app.pages.myPage.descendants.myDropDown.getElement();
elem.options.length=0;//always gives me an error because options doesn't seem to exist in that object.
So for now I've been using the standard HTML dom elements in an AppMaker Html widget and that works okay as long as your select is on the first page. If it's not on the first page I have found that the onChange event can't load Widgets on pages that are not visible. It is interesting to note however that you can change the contents of HTML widgets even if they are on other non visible pages.
Anyway the simple question is how can one load one thing into value and another thing into option text in an AppMaker DropDown Widget?
<option value="value">text</option>
If you have a predefined array for your options and values you could do the following for your onAttach Event of your dropdown:
var options = ['one thing','two thing','three thing'];
var names = ['another one thing','another two thing','another three thing'];
widget.options = options;
widget.names = names;
In this case the values that would get recorded would be the options array, but the items that would be displayed would be from the names array. Hope this gets you on the right path.
I have a grid I created in Gridx which lists a bunch of users. Upon clicking a ROW in the grid (any part of that row), a dialog pops up and shows additional information about that user and actions that can be done for that user (disable user, ignore user, etc.) - when one of these options is selected from the pop up, I want to DISABLE that row. The logic for getting the row, etc. I can take care of, but I can't figure out how to make a grid row actually "appear" disabled and how to make that row no longer clickable.
Is there a simple way to do this? If you aren't familiar with gridx, solutions that apply to EnhancedGrids or other Dojo grids are also appreciated.
Alright now that I have a little more information here is a solution:
Keep a list of all the rows you have disabled so far either inside the Grid widget or in its parent code. Then on the onRowClick listener I would write code like this:
on(grid, "onRowClick", function(e) {
if(disabledRows[rowIndex]) {
return;
}
// Do whatever pop up stuff you want and after
// a user selects the value, you can "disable"
// your row afterwards by adding it to the disabled
// list so that it can no longer be clicked on.
var rowIndex = e.rowIndex;
disabledRows[rowIndex] = true;
// This is just some random class I made up but
// you can use css to stylize the row however you want
var rowNode = e.rowNode;
domClass.add(rowNode, "disabled");
});
Note that domClass is what I named "dojo/dom-class". Hope this helps!
This is perhaps not exactly what you are seaching for:
If you want to hide one or more rows by your own filterfunction you could just add to these rows in the DOM your own class for nodisplay. Here I show you a function for display only those rows which have in a choiceable field/column a value inside your filterlist.
function hideRowFilter(gridId, fieldName, filterList)
{
var store = gridId.store;
var rowId;
store.query(function(object){
rowId = gridId.row(object.id,true).node();
if (filterList.indexOf(object[fieldName]) == -1)
domClass.add(rowId, "noDisplay"); // anzeigen
else
domClass.remove(rowId, "noDisplay"); // verstecken
});
}
CSS:
.noDisplay { display: none; }
So I can for example display only the entries with a myState of 3 or 4 with this call:
hideRowFilter(gridId, 'myState', [3, 4]);
Note that domClass is what I named "dojo/dom-class"
I have a table of four columns. The data in the first column is a name of a group in which I can click on to go to a new page to modify the group data.
I can get the text of that group name, but I am unable to click on it. I'm trying to go through each row and get the status of each group (located in column 4). If it's on hold, I want to modify the data of that group.
Here is my code: Why will it not click on the group name?
List<WebElement> elems = driver.findElements(By.xpath("//table[#id='nameOfTable']/tbody/tr"));
for (WebElement rowElem : elems)
{
List<WebElement> cells = rowElem.findElements(By.xpath("td"));
if(cells.get(3).getText().equalsIgnoreCase("Hold"))
{
System.out.println(cells.get(0).getText()); //
cells.get(0).click; // This will not click on the link
}
}
It is because you are clicking the whole cell, not the link inside the cell. Try:
cells.get(0).findElements(By.TagName("a")).Click();
If the link is an <a> tag it will work, but you can use id, classname, etc... if it isn't.
You would need to say cells.get(0).click();.
I believe you are missing a couple of parentheses...
I have a drop down list that is populated in the page load event from a database table.
The drop down has a DataTextField set to a project name and the DataValueField set to the project id (interger).
Later I change the dropdowlist selected item with this code in the selectedindexchanged event of a gridview
GridViewRow row = GridView1.SelectedRow;
ddlProjectList.SelectedItem.Text = row.Cells[2].Text;
Does Changing the drop down list with this code cause the DataValueField property to change to the correct Project ID number also? If not is there a better way to do this?
=============================================EDIT
actually this code seems to be adding an additional item to the list so that the project i set with this code is listed twice so I don't think my code is correct
This does not change anything else than the text of the selected item in your DropDownList. Do you want to change the text and value of the project, or do you want to select the project from the DropDownList that relates to the selected row in the grid?
To change the project name and id, you'll have to change it in the data source behind the ProjectList. But if you just want to select the related project, you can use this:
var row = GridView1.SelectedRow;
if (ProjectList.Items.FindByText(row.Cells[2].Text) != null)
{
ProjectList.ClearSelection();
ProjectList.Items.FindByText(row.Cells[2].Text).Selected = true;
}
Setting SelectedItem.Text does not actually change the selected item by its text, it changes the text of the currently selected item. You need to use ddl.Items.FindItemByText (or it may be worded FindByText, I forget at the moment) to find the item, then set the ListItem.Selected property to true.
HTH.
You can do
ddlProjectList.FindByText(row.Cells[2].Text).Selected = true;
This will actually set it.
I have a dropdown in which we add certain items after the dropdown is bound by data from the db, hence the need to sort the dropdown arises. So i need to sort a dropdown which can have duplicates. What is the best way of doing this?
Instead of adding items directly to the Dropdown, I would suggest adding them to the data structure that you bind to. If the items in this structure implement IComparable, then you can define a comparison method to apply sorting before the Dropdown is actually bound to the data source.
Assuming you are binding to a Generic List you can try something like this :
var ddlFoo = new List<foo>();
foreach (var lc in myDropDownList.Items)
{
ddlFoo.Add((foo)lc);
}
myDropDownList.DataSource = ddlFoo.OrderBy(dl => dl.fooID);
myDropDownList.Databind();