How to set a scrollbar position of primefaces datatable from last to first?
Actually, I want see the information from bottom to top. Below is my code:
<p:dataTable var="c" value="#{MessagingUserBean.inboxDetails1}" scrollable="true" scrollHeight="517" liveScroll="true" emptyMessage="No Message Found" scrollRows="8" scrollWidth="815" >
Well you can try to not use a liveScroll because you then don't know the end of dataList. Try this and maybe this suit your needs. This will scrolldown to the bottom of your dataTable with a delay.
<h:form prependId="false">
<p:dataTable id="dataTable" var="c" value="#{MessagingUserBean.inboxDetails1}" scrollHeight="517" liveScroll="true" emptyMessage="No Message Found" scrollWidth="815" >
//Your dataTable stuff
</p:dataTable>
</h:form>
<script>
//Get the scrollheight
var s = jQuery('#dataTable .ui-datatable-scrollable-body').prop('scrollHeight');
//Get total size of datatable
var o = jQuery('#dataTable .ui-datatable-scrollable-body').prop('offsetHeight');
//calculate how many times it can scrolldown to set your timer
var t = Math.ceil(s/o);
//Excute scrolldown animation (max scrolldown is scrollHeight - offsetHeight)
$('#dataTable .ui-datatable-scrollable-body').animate({scrollTop:s-0}, t*1000);
</script>
You will need some javascript to do this.
var $scrollable = $(dataTableSelector).children('.ui-datatable-scrollable-body')[0];
$scrollable.scrollTop = $scrollable.scrollHeight;
Where "dataTableSelector" is a selector for your primefaces table (a styleClass for example).
Of course, this assume that the last element in the list you're displaying is actually the first you want to show.
Related
I have a page with nested tabview , like this :
<p:tabView dynamic="true" id="tabView">
<p:tab title="tab1">
<p:tabView dynamic="true" >
<p:tab title="subtab1" >
// Some charts : LineChart , PieChart ...
// Labels working
</p:tab >
<p:tab title="subtab2" >
// Some charts : LineChart , PieChart ...
// !! Labels not working !!
</p:tab>
</p:tabView>
</p:tab>
<p:tab title="tab2">
// Some charts : LineChart , PieChart ...
// Labels working
</p:tab>
</p:tabView>
So the problem is that labels are not working in 'subtab2' , if i switch 'subtab2' and 'subtab1' labels work in 'subtab2' and not in 'subtab1'.
In 'tab1' and 'tab2' no problem !
I'm working with primefaces 5.1.
The same code is working in PF 5.2 .
With PF 5.1 , to make it work, change the dynamic attribute to false in the second tabView.
I'm writing a Firefox add-on and for the <scale> XUL element, onsyncfrompreference doesn't seem to be called (Firefox 14). Here's my preference:
<preferences>
<preference id="pref-sensitivity" name="bbaddon.sensitivity" type="string"/>
...
</preferences>
and here is the scale:
<scale min="1" max="100" increment="1" preference="pref-sensitivity"
id="bb-sensitivity"
onsynctopreference="Application.console.log('onsynctopreference called')"
onsyncfrompreference="Application.console.log('onsyncfrompreference called')" />
The logs are just for debugging at the moment, onsynctopreference is called no problem as it shows up on the console, but there's no entry from onsyncfrompreference. I have a default value defined in defaults.js.
If you look at the implementation of this feature in preferences.xml, onsyncfrompreference will only be called for "editable" elements. As to what is considered "editable", you can see that below. Some elements are always considered editable, others have to specify preference-editable="true" attribute explicitly. In your case it's the latter meaning that your fix would look like this:
<scale min="1" max="100" increment="1" preference="pref-sensitivity"
preference-editable="true" id="bb-sensitivity"
onsynctopreference="Application.console.log('onsynctopreference called')"
onsyncfrompreference="Application.console.log('onsyncfrompreference called')" />
I've worked around this using Javascript:
<script type="text/javascript">
var loaded = false;
//load preferences
var prefs = Components.classes["#mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService)
.getBranch("extensions.bb");
prefs.QueryInterface(Components.interfaces.nsIPrefBranch2);
function loadpref() //call this in the prefwindow onload
{
document.getElementById('bb-sensitivity').value = prefs.getCharPref('sensitivity');
loaded = true;
}
function setpref(sensitivity)
{
if(loaded) //onchange for scale fires before onload for the window
{
prefs.setCharPref('sensitivity',sensitivity);
}
}
</script>
and the scale element:
<scale min="1" max="100" increment="1"
preference="pref-sensitivity"
id="bb-sensitivity"
onchange="setpref(this.value);"
/>
I'll leave this question open for now to see if anyone else can help. I'd still like to do this the 'correct' way.
I'm developing an extension for FireFox. I use a XUL deck element that contains a XUL browser element. Unfortunately, whenever the page displayed in the browser has an HTML title attribute, the value of this title attribute will not show up as a tooltip.
How can I get tooltips to display correctly?
There is no mechanism to automatically display title attributes in tooltips - the browser window has special code for that and you need to replicate this code in your extension. This means that you need to define a <tooltip> element, e.g.:
<popupset>
<tooltip id="browserTooltip" onpopupshowing="return fillTooltip(this);"/>
</popupset>
You should use this tooltip in your <browser> element, like this:
<browser tooltip="browserTooltip"/>
And you should create a fillTooltip() function that will be called whenever your tooltip shows up. It will need to look at the HTML element that the mouse pointer hovers over, check its title attribute and put the value of the attribute into the tooltip. The function performing this job in Firefox is FillInHTMLTooltip() though you might want to go with a simpler variant like this (untested code):
function fillTooltip(tooltip)
{
// Walk up the DOM hierarchy until we find something with a title attribute
var node = document.tooltipNode;
while (node && !node.hasAttribute("title"))
node = node.parentNode;
// Don't show tooltip if we didn't find anything
if (!node)
return false;
// Fill in tooltip text and show it
tooltip.setAttribute("label", node.getAttribute("title"));
return true;
}
I found the solution for those who are interested, it's by adding a tooltip property to the XUL browser element with the following value:
tooltip="aHTMLTooltip"
Or adding it programmatically using javascript like this:
browser.setAttribute('tooltip','aHTMLTooltip');
for more details check: https://bugzilla.mozilla.org/show_bug.cgi?id=451792#c1
Working example:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window id="mainWindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" title="NanoFL" width="800" height="600" persist="screenX screenY width height sizemode">
<script>
<![CDATA[
function fillTooltip(tooltip)
{
var nodes = document.getElementById("browser").contentWindow.document.querySelectorAll(":hover");
for (var i=nodes.length-1; i>=0; i--)
{
if (nodes[i].hasAttribute("title"))
{
tooltip.setAttribute("label", nodes[i].getAttribute("title"));
return true;
}
}
return false;
}
]]>
</script>
<browser id="browser" src="chrome://nanofl/content/index.html" flex="1" disablehistory="true" tooltip="browserTooltip" />
<tooltip id="browserTooltip" onpopupshowing="return fillTooltip(this)"/>
</window>
I'm trying to get an element to move from right to left in XUL. I am doing this with a toolbar and want one toolbarbutton w/ a label to remain anchored to the right, while one of them moves from right to left, starting to the left of the anchor.
I'm trying to achieve this effect by modifying marginLeft, but my element stays still. I'm not really sure why it does not move.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE overlay >
<overlay id="my-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript">
// Install load handler
var marginLeft = 0;
window.addEventListener("load", function(e) {
function moveIt() {
document.getElementById("moveit").style.marginLeft = marginLeft + "px";
marginLeft -= 30;
}
setInterval(moveIt, 1000);
}, false);
</script>
<vbox id="browser-bottombox">
<toolbar id="theToolbar">
<!-- holds the scrolling items and the refresh time -->
<hbox id="scrollingItemContainer" flex="1" align="end">
<!-- container for our scrolling items -->
<spacer flex="1"/>
<hbox id="movingItems" align="end">
<toolbarbutton id="moveit" label="moving"/>
</hbox>
<hbox>
<toolbarbutton id="rightAnchor" label="right"/>
</hbox>
</hbox>
</toolbar>
</vbox>
</overlay>
Any help you can provide will be helpful. I've tried this on FF4, but I think the problem exists on FF3 as well.
I should note that if I add a spacer with flex=1 after scrollingItemContainer then I see the item move, but it is not anchored to the right.
I've create an AdvancedDataGrid where most of the cell are based on an ItemRenderer. The custom ItemRenderer (SoundBox) extends VBox. This custom component allow for simple changes in the background color based on user clicking on a cell.
Here is the snippet of the AdvancedDataGrid (nothing too advanced):
<mx:AdvancedDataGrid id="fsfw" dataProvider="{fsfWordList}" sortableColumns="false" >
<mx:groupedColumns>
<mx:AdvancedDataGridColumn width="35" dataField="wordcount" headerText=" "/>
<mx:AdvancedDataGridColumn id="myWord" width="150" headerText="TEST ITEMS">
<mx:itemRenderer>
<mx:Component>
<components:SoundBox width="100%" letterSound="{data.word}" />
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
<mx:AdvancedDataGridColumn width="200" headerText="Correct / 2 points" dataField="sound1">
<mx:itemRenderer>
<mx:Component>
<components:SoundBox width="100%" letterSound="{data.sound1}" pointColumn="2"/>
</mx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
</mx:groupedColumns>
</AdvancedDataGrid>
What I'm trying to do is change the background color of (let's just say I have one row of data) row1, cell1 to green when the user clicks on cell3 of row1.
I'm unsure as to how I get access to those items (ItemRenderer/SoundBox) within the Grid.
Any Ideas? THX!
look at the following code,,, it will return the item rendrer of given row and colomn index.. Extended the Advance dataGrid and define this function in the extended class,to get it worked, then use it like "CustomADG.indicesToItemRenderer(0,0)" and in that reuturend object try to get the reference to soundComponent.
public function indicesToItemRenderer(rowIndex:int, colIndex:int):IListItemRenderer
{
var firstItemIndex:int = verticalScrollPosition - offscreenExtraRowsTop;
if (rowIndex < firstItemIndex ||
rowIndex >= firstItemIndex + listItems.length)
{
return null;
}
return listItems[rowIndex - firstItemIndex][colIndex];
}