We have a af:table with following properties:
rowSelection="multiple"
editingMode ="clickToEdit"
If you click on a row to select it, then scroll down so new data is being fetched, then press shift and click on an other row (to select multiple rows), only the last row is selected.
Did anybody have the same problem? How can it be fixed?
Version: 11.1.1.6.0
My table def:
<af:table
value="#{bindings.EmployeesView.collectionModel}"
var="row"
rows="#{bindings.EmployeesView.rangeSize}"
emptyText="#{bindings.EmployeesView.viewable ? 'No data to display.' : 'Access Denied.'}"
fetchSize="#{bindings.EmployeesView.rangeSize}"
rowBandingInterval="0"
filterModel="#{bindings.EmployeesViewQuery.queryDescriptor}"
queryListener="#{bindings.EmployeesViewQuery.processQuery}"
filterVisible="false"
varStatus="vs"
rowSelection="multiple"
id="t3"
editingMode="clickToEdit"
partialTriggers=":::pcDep:tDep"
contentDelivery="immediate"
summary="Employees table">
Related
I think of simplifying the click events and instead of attach them on column renderer (I use React), I tried to attach a single onCellClicked event (where I do get all the data for the row) and do a switch for... column. On first column there will be a delete button, on second something else, etc. I do have some colDef and column, but no index for the column. Instead I have a colId, which isn't what I need. I do have a colDef, where column header could be used, but for my case I don't have headers. I can't imagine how they omitted the column index.
You can get all columns and find its index based on the field property if you don't provide the colId:
<AgGridReact
{...}
onCellClicked={(e) => {
const field = e.colDef.field;
const colIndex = e.columnApi
.getAllColumns()
?.findIndex((col) => col.getColDef().field === field);
console.log(field, colIndex);
}}
/>
I'm having the two types of check-boxes one is for selectAll check-box in the data table header, and another type selecting the check-box for each row.
I'm doing a operation, So I need to show the confirmation message, How do I get the count of the selected check-boxes from the Managed Bean.
My code was written in JSF 1.2.
I can able to do select all records, select records, ManagedBean is working fine, But I need to get how many of them got selected for deletion.
Here is the JSF code,
<i:commandLink id="delete"
onclick="if (!confirm('#{managedBean.deleteSelectedCount}')) return false;"
action="#{managedBean.deleteRecords}"
title="Delete records"
immediate="true">
<i:graphicImage url="images/icons/delete.gif" alt="Delete records" />
</i:commandLink>
;
;//Some coding
;
//Data table code starts
<i:dataTable id="caseDataTable"
<h:column>
<f:facet name="header">
<i:selectBooleanCheckbox id="selectAllRecords" title="select All records"
value="#{managedBean.selectAll}">
<a4j:support event="onclick" reRender="caseDataTable,globalMessages" action="#{managedBean.actionSelectAllRecordss}" onsubmit="showBusyIndicator();" oncomplete="hideBusyIndicator();" />
</i:selectBooleanCheckbox>
</f:facet>
<h:outputLabel for="selectCheckbox" value="selectCheckbox"/>
<i:selectBooleanCheckbox id="selectCheckbox"
title="select a record" value="#{managedBean.selected}" >
<a4j:support event="onclick" reRender="selectAllRecords, globalMessages" action="#{managedBean.actionSelectionChange}"
onsubmit="showBusyIndicator();" oncomplete="hideBusyIndicator();"/>
</i:selectBooleanCheckbox>
</h:column>
Possible solution is to use h:inputHidden component (I think it exists in JSF 1.2. If not, you can find some alternative).
For example
Add h:inputHidden to the page
<h:inputHidden id="selectedCountHidden" value="#{managedBean.deleteSelectedCount}"/>
Each time you click on header check box or any of row check boxes, calculate deleteSelectedCount value and re-render h:inputHidden. Something like
<i:selectBooleanCheckbox id="selectCheckbox" title="select a record" value="#{managedBean.selected}" >
<a4j:support event="onclick" reRender="...,selectedCountHidden,..."
And now, since h:inputHidden will always hold deleteSeletedCount value, you can read its value via java script so there is no need for re-loading the page when you click on commandLink
<i:commandLink id="delete"
onclick="if(!confirm(document.getElementById('form:selectedCountHidden').value))return false;"..../>
Note that if you have form with id defined, you will need to call
document.getElementById('form:selectedCountHidden').value
Otherwise just call
document.getElementById('selectedCountHidden').value
In any case, inspect page source and you will find the exact id of p:inputHidden.
I have an XML Field that contains data similar to how .Net constructs controls within forms. Suppose you have a windows Form, you can add multiple controls to the form and they show up under the .Controls property. Some of the controls themselves can also have controls such as panels, group boxes etc. Similar to what is shown in the xml below.
<Form>
<Name>MyForm</Name>
<TabCtrl>
<Name>Tab1</Name>
<Controls>
<TextboxCtrl>
<Name>MyTextBox</Name>
<Location>3,10</Location>
<Tag>34</Tag>
</TextboxCtrl>
<Label>
<Name>MyLabel</Name>
<Location>23,3</Location>
<Tag>19</Tag>>
</Label>
<Panel>
<Name>myPanel</Name>
<Controls>
<TextboxCtrl>
<Name>MyTextBox2</Name>
<Location>36,210</Location>
<Tag>34</Tag>
</TextboxCtrl>
</Controls>
</Panel>
</Controls>
</TabCtrl>
<TabCtrl>
<Name>Tab2</Name>
<Controls>
...
</Controls>
</TabCtrl>
There are thousands of rows in a DB table each with xml that itself consists of up sometimes 1000’s of “controls”. I’m looking for a way to query for TabCtrl/Name node when that TabCtrl contains a control that has the Tag of 34.
I can limit the rows by this query using xPath
Select theXML from ViewTable where theXML.exist('//Tag[.="34"]') = 1
Further, I can get the Name of the control rather than the entire xml with this:
Select theXML.query('//*[Tag="34"]/Label/text()') as 'Control Name'from ViewTable where theXML.exist('//Tag[.="34"]') = 1
How do I get the TabCtrl/Name ? The path from the element that contains the matching Tag could go through 1-n levels of Controls nodes so using the Xpath statement won’t work. The TabCtrl will all ways be a direct child of the Form node
Possible Solutions :
One possible way to get the text from TabCtrl/Name containing a control that has the Tag of 34 :
Select theXML.query('//TabCtrl[Controls/*/Tag="34"]/Name/text()') as 'Control Name'
Or if you need to get to the <TabCtrl> starting from it's descendant then you can always climb up the tree using parent::element_name or ancestor::element_name or .. :
Select theXML.query('//*[Tag="34"]/ancestor::TabCtrl/Name/text()') as 'Control Name'
Difference between axes mentioned above :
parent::element_name : Go one level up to a specific parent element
ancestor::element_name : Go one or more level up to a specific ancestor element
.. : Go one level up to a parent element with any name
Shred the XML on Form/TabCtrl using nodes(), check the existence of Tag=34 for each shredded node using exist() and finally get the value from Form/TabCtrl/Name with the value() function.
select TC.X.value('(Name/text())[1]', 'nvarchar(100)')
from YourTable as T
cross apply T.theXML.nodes('/Form/TabCtrl') as TC(X)
where TC.X.exist('*//Tag/text()[. = "34"]') = 1
SQL Fiddle
This query will return the TabCtrl/Name for any TabCtrl that has a Controls node that has a grand child Tag that =s 34:
DECLARE #theXML XML = '<Form>
<Name>MyForm</Name>
<TabCtrl>
<Name>Tab1</Name>
<Controls>
<TextboxCtrl>
<Name>MyTextBox</Name>
<Location>3,10</Location>
<Tag>34</Tag>
</TextboxCtrl>
<Label>
<Name>MyLabel</Name>
<Location>23,3</Location>
<Tag>19</Tag>>
</Label>
<Panel>
<Name>myPanel</Name>
<Controls>
<TextboxCtrl>
<Name>MyTextBox2</Name>
<Location>36,210</Location>
<Tag>34</Tag>
</TextboxCtrl>
</Controls>
</Panel>
</Controls>
</TabCtrl>
<TabCtrl>
<Name>Tab2</Name>
<Controls>
...
</Controls>
</TabCtrl>
</Form>'
Select #theXML.query('//TabCtrl/Controls/*[Tag="34"]/../../Name') as 'Control Name'
Output:
<Name>Tab1</Name>
I'm not 100% sure that's what you're looking for, but this is probably the general pattern you want to follow here, with an additional query if you need to get more deeply nested Tag=34 nodes.
I am working on JDeveloper 11g Release 2. I am having af:input text elements and af:selectonechoice elements in my form. The problem is with af:selectonechoice element. After selecting a value from this choice list, it refreshes the values of other elements. I mean the values of af:inputtext are lost or the fields becomes empty.
The code for af:selectonechoice is as follows:
<af:selectOneChoice label="User Permission" id="soc"
value="#{row.bindings.UserPermission.inputValue}"
autoSubmit="true" valueChangeListener="#{SomeBean.setSomeValue}">
<af:selectItem label="Administrator" value="ADMIN" id="si1"/>
<af:selectItem label="Manager" value="MANAGER" id="si2"/>
<af:selectItem label="Employee" value="EMPLOYEE" id="si3"/>
</af:selectOneChoice>
Below is the code for input text:
<af:inputText value="XXX" label="XXX" id="id3" readOnly="true" partialTriggers="soc" >
</af:inputText>
Only the above inputText has partialtriggers. This works fine. Also I am sure that other input elements not having any partial triggers. Why the other input elements also being updated. Any ideas regarding this.
EDIT:
<af:column sortProperty="#{bindings.TasksView1.hints.TaskNo.name}"
sortable="true" headerText="Task No" id="c2">
<af:inputText value="#{row.bindings.TaskNo.inputValue}"
label="#{bindings.TasksView1.hints.TaskNo.label}" id="id3"
partialTriggers="soc">
</af:inputText>
</af:column>
And Code for ValueChangeLister is:
public void generateTaskNo(ValueChangeEvent valueChangeEvent){
DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding iterBind = (DCIteratorBinding)dcBindings.get("TasksView1Iterator");
valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance());
String task_code = (String)iterBind.getCurrentRow().getAttribute("USERPERMISSION");
task_code = task_code +'-';
String task_no = (String)iterBind.getCurrentRow().getAttribute("TaskNo");
task_code = task_code + task_no;
iterBind.getCurrentRow().setAttribute("TaskNo", task_code );
}
Here i am getting the SelectOneChoice value and Input text value[with id 'id3' ]. Based on the selected choice's value[Admin,manager,employee] i will set the value[TaskNo] in that input text. This should not affect other input fields in the form. But the problem is all other input fields are also updating and losing their previous values. I am sure those input fields don't have any partial triggers.
Your select one choice (SOC) set as auto submit = true. Then any element had partial triggers for SOC, Then that elements get refreshed. element SOC submit his value to server and other elements listen that value. listening elements needs to refreshed for update his value for SOC
The solution for this is if you use select one choice component with list of values you want store the id in database. For suppose your storage "ID" datatype consist integer but in database storage column datatype consist Varchar then soc components automatically refreshed when click save.so let you check the db column and list of values(lov) store value.
i have table view like below
<table>
<tr><th>Username</th>
<th>Departemen</th><th>Created By</th><th>Created Date</th><th>Last Update By</th><th>Last Update Date</th><th>Aksi</th></tr>
<?php
$sql = "SELECT TOP 20 * FROM tblMstUser where CompanyDeptID ='11' or CompanyDeptID ='12' order by LoginID";
$tampil = mssql_query($sql) ;
while($r=mssql_fetch_array($tampil)){
echo "<tr><td>$r[LoginID]</td>
<td>$r[LoginName]</td>
<td>$r[CreatedBy]</td>
<td>$r[CreatedDate]</td>
<td>$r[LastUpdatedBy]</td>
<td>$r[LastUpdatedDate]</td>
<td>
<button id='edit' onclick=\"popup_window_show('#sample', { pos : 'tag-right-down', parent : this});\"'><image src='images/Edit.png'/>Edit</button> |
<button id='delete'><image src='images/delete.png'/>Hapus</button>
</td>
</tr>";
$no++;
}
?>
</table>
my purpose when user click "edit" all of field in popup will filled by related data using LoginID as parameter in my sql. i use ms sql 2008 as mya database server.
my problem how i can get a single data from array "$r[LoginID]" using Jquery for each row.
pass LoginID to the function as parameter along with button onClick, eg.
<button id='edit' onclick=\"popup_window_show('#sample', '$r[LoginID]' ,{ pos : 'tag-right-down', parent : this});\"'>
and fire ajax call with jQuery to a page, the page returns data related to LoginID and fill all editable fileds in the edit form.