Extjs domQuery using grid.up().query() - javascript

I am facing problem in using the domquery, to get focus on the control previous to grid when the grid cell is in edit mode, What i am trying is
1.check the grid tabindex add 1 to it, gridTabIndex = grid.dom.tabindex - 1
2.do grid.up() to look out for main form ,
3.then search using domquery form.query('input[tabindex = gridTabIndex]') for the field with the tabindex = grid.tabindex - 1
using grid.up().query() gives the below output as shown in image
So the point 3 is where i am facing problem. it gives an empty array // output is []
Any kind of help is appreciated.

form.query doesn't query Dom Elements. It queries ExtJs Components. However form.getEl().query do query for Dom Elements. Give it a try. (Notice, Ext.dom.Element.query is available only since 4.1.0)

Related

How to select column names in webdriverio?

I am new to webdriverio. I need to select column names for a table which is defined as div tags in UI grid instead of tr, td. I am able to select the number of available column names as 6 with below xPath but when I execute the same xPath I am getting available elements as 1.
fundSearchTable(){
return $$("//ag-grid-angular//*[#class='ag-header-container']//*[#class='ag-header-cell ag-focus-managed ag-header-cell-sortable']//*[#class='ag-header-cell-text']")
}
const fundColumnList= await this.fundSearchTable;
console.log("number of childs:"+ await fundColumnList.length) //logs 1
Inspect in DOM1
Can someone help me with this as I need to interact with tables more often?
As you posted images it is difficult to write the xPath. Please use below xPath's to select the column names.
//span[text()='Fund Number'] or //div[#col-id='fundNumber']
//span[text()='Fund Name'] or //div[#col-id='fundName']
//span[text()='Fund Acronym'] or //div[#col-id='fundAcronym']
I am able to solve this. Issue was that the page is not loading by the time the command is executed to get the column names. I gave the wait time. And for the "for loop", I gave the length as row.length-1.
But still my result was inconsistent.

How can I write the code to append all of the items(XPages)?

I have many documents in Notes, all of the documents have a different form, like this picture :
(possibly like pic 1, pic 2, or pic 3)
How can I write the code in Xpages?
use the "computed field"? Or use the "input text"?
I used the "input text".But only for one item, not for all.
var doc = purchase.getDocument();
var A0 = doc.getItemValueString("DAY_A0");
if(A0 != 0){
return "Division processing";
}
If the form not only has one item, like the pics. How can I write the code to append all of the items?
I'm making the following assumptions here:
You have 10 fields in the document with numbers that might or might not be > 0
The 11th value (Total) shall be computed
You want to show one document at a time, not a list
You know how to add a data source to a page
Version 1:
Create a regular XPages form, use the wizard when adding the document data source. It now would show also the field with 0 values
Click on each ROW and change visibility property to computed (make sure you hit the row, not the cell or field) and add a visibility formula based on the field oof that row. Something like doc.DAY_A0 > 0
Add a computed field where you add the values of all 11 fields
done
Version 2:
in the page open event, get a handle on the document and compute a scoped variable that only contains the values you are interested in. Could be messy since you need a label (that is not your field name) and a value
Use a repeat control to render the values
Hope that helps

Access rendered items

Playing around with Slickgrid. But got some questions that I'm not figurate out.
I have made an Regex filter on two X cells, and it works surprisingly well.
But for every time you filter or make other actions i want to flash all incorrect fields with cellFlash or highlighter.
Atm i have made a formatter with same regex as filter uses but it seems not 100% correct.
The problem when i'm using cellFlash is that it trigger the animation on ALL rows not only the rows thats rendered.
I'm not sure that i'm triggering the flashcell on correct callback/stage, I did it on my filter function i saved all incorrect rows in an array then i loop them throught and trigger flash.
So is it possible to get all items thats rendered in Viewport? Haven't find any information about this. Only data i can get out from getRenderedViewport.. is pxls. getRenderedRange() or getViewport()..
If you need to do processing on each data item in the current slick grid viewport, you can use getRenderedRange() to get the range of data item indexes that are rendered. You could then use that to get each visible data item
function forEachItemInViewport(fn) {
var range = slickGrid.getRenderedRange();
var bottom = range.bottom;
while(bottom--) {
var dataItem = slickGrid.getDataItem(bottom);
fn(dataItem);
}
}
forEachItemInViewport(function (item) {
// do your work on each item in viewport
});

How to update ZK Grid values from jQuery

I have three Tabs and in each tab, I have a Grid.
The data for each Grid is coming from a database, so I am using rowRenderer to populate the Grids. The following code is common for all three Grids:
<grid id="myGrid1" width="950px" sizedByContent="true" rowRenderer="com.example.renderer.MyRowRenderer">
The rows are constructed from Doublebox objects. The data is populated successfully.
The Problem:
I need to handle multiple-cell editing on the client side. The editing is done via mouse-clicking on a particular cell and entering a value.
As example let's say that the user edits first cell on the first row and the value should be
propagated to all other cells on the same row and in all three Grids (so also the two Grids which the user currently does not see, because they are in tabpanes).
I am using jQuery to do this value propagation and it works OK.
I am passing the jQuery as follows:
doublebox.setWidgetListener(Events.ON_CHANGING, jQuerySelectors);
doublebox.setWidgetListener(Events.ON_CHANGE, jQuerySelectors);
This makes it possible to change the value in 1 cell and the change is instantly (visually) seen in all other cells filtered by jQuery selectors.
The problem is that the value is visually distributed to all the cells, but when I try to save the Grid data back to the database, the background values are the old ones.
I am assuming that ZK-Grid component is not aware that jQuery changed all the cell values. Nevertheless if I manually click on a cell that already has the NEW value (enter/leave/change focus) when I save the grid the NEW value is correct in that particular cell. Maybe that's a hint how can I resolve this.
Code of how I extract the Grid values:
Grid tGrid = (Grid) event.getTarget().getFellow("myGrid1");
ListModel model = tGrid.getModel();
MyCustomRow tRow = (MyCustomRow)model.getElementAt(i);
The model for my Grid is a List of MyCustomRow:
myGrid1.setModel(new ListModelList(List<MyCustomRow> populatedList));
I have a couple of assumptions, but whatever I have tried, hasn't worked. I have in mind that jQuery events and ZK-Events are different and probably isolated in different contexts. (Although I have tried to fire events from jQuery and so on..)
Do you have any suggestions? As a whole is my approach correct or there's another way to do this? Thanks for your time in advance!
Your problem is exactly what you are expecting.
Zk has it's own event system and do not care about your jq,
cos it's jq and zk don't observ the DOM.
The ways to solve your problem.
Use the "ZK-Way":
Simply listen at server-side and chage things there.
I am not sure if not selected Tabs
are updateable, but I am sure you could update the Grid
components on the select event of the Tab.
Fire an zk-event your self:
All you need to know, is written in the zk doc.
Basically, you collect your data at client side, send
an Event to the server via zAu.send() extract the
data from the json object at serverside and update your Grids
I would prefer the first one, cos it's less work and there should not be
a notable difference in traffic.
I post the solution we came up with:
This is the javascript attached to each Doublebox in the Z-Grid
//getting the value of the clicked cell
var currVal = jq(this).val();
//getting the next cell (on the right of the clicked cell)
objCells = jq(this).parents('td').next().find('.z-doublebox');
// if there's a next cell (returned array has length) - set the value and
// fire ZK onChange Event
if (objCells.length) {
zk.Widget.$(jq(objCells).attr('id')).setValue(currVal);
zk.Widget.$(jq(objCells).attr('id')).fireOnChange();
} else { //otherwise we assume this is the last cell of the current tab
//So we get the current row, because we want to edit the cells in the same row in the next tabs
var currRow = jq(this).parents('tr').prevAll().length;
//finding the next cell, on the same row in the hidden tab and applying the same logic
objCellsHiddenTabs = jq(this).parents('.z-tabpanel').next().find('.z-row:eq(' + currRow + ')').find('.z-doublebox');
if (objCellsHiddenTabs.length) {
zk.Widget.$(jq(objCellsHiddenTabs).attr('id')).setValue(currVal);
zk.Widget.$(jq(objCellsHiddenTabs).attr('id')).fireOnChange();
}
}
The java code in the RowRenderer class looks something like this:
...
if (someBean != null) {
binder.bindBean("tBean", someBean);
Doublebox box = new Doublebox();
setDefaultStyle(box);
row.appendChild(box);
binder.addBinding(box, "value", "tBean.someSetter");
...
private void setDefaultStyle(Doublebox box) {
box.setFormat("#.00");
box.setConstraint("no negative,no empty");
box.setWidth("50px");
String customJS = ""; //the JS above
//this is used to visually see that you're editing multiple cells at once
String customJSNoFireOnChange = "jq(this).parents('td').nextAll().find('.z-doublebox').val(jq(this).val());";
box.setWidgetListener(Events.ON_CHANGING, customJSNoFireOnChange);
box.setWidgetListener(Events.ON_CHANGE, customJS);
}
What is interesting to notice is that ZK optimizes this fireOnChange Events and send only 1 ajax request to the server containing the updates to the necessary cells.

dojo grid: naviagion

I am exploring dojo grid, and could not find a good example of how to handle navigation by clicking on the row.
There is a simple grid example here
How to extend the code with the following requirement
handle doubleclick event on row items
read the identifier and extract the value corresponding to the selected row ( 12 for first row)
redirect to {current domain}/view/{identifier} (like www.example.com/view/12)
any help would be a great time saver...
thanks.
EDIT: added javascript tag so that more user may see this post (only 9 so far with dojo alone)
I had to solve problems 1 and 2 above.
You can use dojo.connect to connect the grid to the onRowClick event. For example, if you have a grid of the form:
<div dojoType="dojox.grid.DataGrid" jsId="grid" id="myGrid" structure="layout" selectionMode="single"></div>
You can then call in JavaScript:
dojo.connect(grid, "onRowClick", clickMethod);
clickMethod can then access the data from the row as follows:
function clickMethod(event) {
...
selected_index = grid.focus.rowIndex;
selected_item = grid.getItem(selectedIndex);
//Not sure if this is the most efficient way but it worked for me
selected_id = grid.store.getValue(selectedItem, "field_name_from_store");
...
}
I imagine you can do a location.href or similar after that.

Categories

Resources