how to get the data from a table primeng? - primeng

I want to go through my table to see the edited records:
<p-dataTable #dtParam [value]="parameterSecurity" [immutable]="false" [(selection)]="selectParam" dataKey="parameterId" [editable]="true" (onEditInit)="cellDirty($event)">
<p-column [style]="{'max-width':'300px'}" [editable]="true" field="parameterId" header="Parámetro"></p-column>
<p-column [style]="{'max-width':'300px'}" [editable]="true" field="value" header="Valor"></p-column>
<p-column [style]="{'max-width':'300px'}" [editable]="true" field="description" header="Descripción"></p-column>
</p-dataTable>

onEditComplete provides the column info and the row data that was edited.
From the primeng site
onEditComplete: Callback to invoke when cell edit is completed.
event.column: Column object of the cell
event.data: Row data
event.index: Row index

Related

Cognos analytics multiple measures in a single cell

Is it possible to put multiple measures in a single crosstab cell? For example, put a 2x2 table in a cell and drop a measure in each cell of the table? I've tried doing that and the values just repeat across rows.
If you have a crosstab with time on the column edge and product line on the row edge, you can nest the Quantity and Revenue measure under the time, then set the box type to none on the labels so it looks like two values in a single cell. You may need to play around with the borders a bit too.
Here is a sample spec:
<report xmlns="http://developer.cognos.com/schemas/report/15.4/" expressionLocale="en-us" useStyleVersion="11.5">
<drillBehavior/>
<layouts>
<layout>
<reportPages>
<page name="Page1">
<style>
<defaultStyles>
<defaultStyle refStyle="pg"/>
</defaultStyles>
</style>
<pageBody>
<style>
<defaultStyles>
<defaultStyle refStyle="pb"/>
</defaultStyles>
</style>
<contents><crosstab horizontalPagination="true" name="Crosstab1" refQuery="Query1">
<crosstabCorner>
<contents/>
<style>
<defaultStyles>
<defaultStyle refStyle="xm"/>
</defaultStyles>
</style>
</crosstabCorner>
<noDataHandler>
<contents>
<block>
<contents>
<textItem>
<dataSource>
<staticValue>No Data Available</staticValue>
</dataSource>
</textItem>
</contents>
<style>
<CSS value="padding:16px;"/>
</style>
</block>
</contents>
</noDataHandler>
<style>
<CSS value="border-collapse:collapse"/>
<defaultStyles>
<defaultStyle refStyle="xt"/>
</defaultStyles>
</style>
<crosstabColumns><crosstabNode><crosstabNestedNodes><crosstabNode><crosstabNodeMembers><crosstabNodeMember refDataItem="Revenue" edgeLocation="e3"><style><defaultStyles><defaultStyle refStyle="ml"/></defaultStyles><CSS value="display:none"/></style><contents><textItem><dataSource><memberCaption/></dataSource></textItem></contents></crosstabNodeMember></crosstabNodeMembers></crosstabNode><crosstabNode><crosstabNodeMembers><crosstabNodeMember refDataItem="Quantity" edgeLocation="e4"><style><defaultStyles><defaultStyle refStyle="ml"/></defaultStyles><CSS value="display:none"/></style><contents><textItem><dataSource><memberCaption/></dataSource></textItem></contents></crosstabNodeMember></crosstabNodeMembers></crosstabNode></crosstabNestedNodes><crosstabNodeMembers><crosstabNodeMember refDataItem="Year" edgeLocation="e1"><style><defaultStyles><defaultStyle refStyle="ml"/></defaultStyles></style><contents><textItem><dataSource><memberCaption/></dataSource></textItem></contents><propertyList><propertyItem refDataItem="Revenue"/><propertyItem refDataItem="Quantity"/></propertyList></crosstabNodeMember></crosstabNodeMembers></crosstabNode></crosstabColumns><crosstabRows><crosstabNode><crosstabNodeMembers><crosstabNodeMember refDataItem="Product line" edgeLocation="e2"><style><defaultStyles><defaultStyle refStyle="ml"/></defaultStyles></style><contents><textItem><dataSource><memberCaption/></dataSource></textItem></contents></crosstabNodeMember></crosstabNodeMembers></crosstabNode></crosstabRows><crosstabIntersections><crosstabIntersection row="e2" column="e3"><style><CSS value="border-right-style:none"/></style></crosstabIntersection><crosstabIntersection row="e2" column="e4"><style><CSS value="border-left-style:none"/></style></crosstabIntersection></crosstabIntersections><crosstabFactCell><contents><textItem><dataSource><cellValue/></dataSource></textItem></contents><style><defaultStyles><defaultStyle refStyle="mv"/></defaultStyles></style></crosstabFactCell></crosstab></contents>
</pageBody>
</page>
</reportPages>
</layout>
</layouts>
<queries><query name="Query1"><source><model/></source><selection><dataItem aggregate="none" rollupAggregate="none" name="Year"><expression>[Sales (query)].[Time].[Year]</expression><XMLAttributes><XMLAttribute output="no" name="RS_dataType" value="1"/><XMLAttribute output="no" name="RS_dataUsage" value="0"/></XMLAttributes></dataItem><dataItem aggregate="none" rollupAggregate="none" name="Product line"><expression>[Sales (query)].[Products].[Product line]</expression><XMLAttributes><XMLAttribute output="no" name="RS_dataType" value="3"/><XMLAttribute output="no" name="RS_dataUsage" value="0"/></XMLAttributes></dataItem><dataItem aggregate="total" name="Revenue"><expression>[Sales (query)].[Sales].[Revenue]</expression><XMLAttributes><XMLAttribute output="no" name="RS_dataType" value="2"/><XMLAttribute output="no" name="RS_dataUsage" value="2"/></XMLAttributes></dataItem><dataItem aggregate="total" name="Quantity"><expression>[Sales (query)].[Sales].[Quantity]</expression><XMLAttributes><XMLAttribute output="no" name="RS_dataType" value="1"/><XMLAttribute output="no" name="RS_dataUsage" value="2"/></XMLAttributes></dataItem></selection></query></queries><XMLAttributes><XMLAttribute output="no" name="RS_CreateExtendedDataItems" value="true"/><XMLAttribute output="no" name="listSeparator" value=","/><XMLAttribute output="no" name="decimalSeparator" value="."/></XMLAttributes><modelPath>/content/folder[#name=&apos;Samples_LG_DQ&apos;]/folder[#name=&apos;Models&apos;]/package[#name=&apos;GO Sales (query)&apos;]/model[#name=&apos;model&apos;]</modelPath></report>

How to get Parent Table "Record Id" (Auto generated id) of SalesForce in MuleSoft

I am trying to access parent "Record ID" (Auto generated ID) in a MULESOFT Flow and store it into child table of SalesForce and store that record id in one variable and pass it to child table through DataWeave Transformation. I am using one flow for this task. Can anyone please tell me how can i get parent table Record ID? Thanks.
Here is my flow Confi. XML file
<flow name="shoppingcartpocmcpostsfuserFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/customeruser" allowedMethods="POST" doc:name="HTTP"/>
<object-to-byte-array-transformer doc:name="Object to Byte Array"/>
<dw:transform-message doc:name="Transform Message" metadata:id="4851f81e-2a1b-4e5e-a34f-cc328e6dd23d">
<dw:input-payload mimeType="application/json"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
[{
Name: payload.ShoppingCartUser.ShoppingCartUserName,
FirstName__c: payload.ShoppingCartUser.FirstName,
LastName__c: payload.ShoppingCartUser.LastName,
EmailID__c: payload.ShoppingCartUser.EmailID,
PhoneNumber__c: payload.ShoppingCartUser.PhoneNumber,
CompanyName__c: payload.ShoppingCartUser.Company,
CustomerType__c: payload.ShoppingCartUser.Customer_Type
}]]]></dw:set-payload>
</dw:transform-message>
<sfdc:create config-ref="Salesforce__Basic_Authentication" type="MS_ShoppingCartUser__c" doc:name="Salesforce Connector for User Details">
<sfdc:objects ref="#[payload]"/>
</sfdc:create>
<object-to-string-transformer doc:name="Object to String"/>
<set-variable variableName="id" value="#[flowVars.id]" doc:name="Variable"/>
<dw:transform-message doc:name="Transform Message for User Address" metadata:id="4851f81e-2a1b-4e5e-a34f-cc328e6dd23d">
<dw:input-payload mimeType="application/json"/>
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
[{
AddressLine1__c: payload.ShoppingCartUser.AddressLine_1,
AddressLine2__c: payload.ShoppingCartUser.AddressLine_2,
CountyName__c: payload.ShoppingCartUser.County,
City__c: payload.ShoppingCartUser.City,
Country__c: payload.ShoppingCartUser.Country,
State__c: payload.ShoppingCartUser.State,
ZipCode__c: payload.ShoppingCartUser.Zipcode,
EmailID__c: id
}]]]></dw:set-payload>
</dw:transform-message>
<sfdc:create config-ref="Salesforce__Basic_Authentication" type="MS_ShoppingCart__c" doc:name="Salesforce Connector for User Address">
<sfdc:objects ref="#[payload]"/>
</sfdc:create>
<object-to-string-transformer doc:name="Object to String"/>
</flow>
The sfdc:create operation will return a 'Result' https://docs.mulesoft.com/connectors/salesforce/salesforce-connector-reference-96#Result
It has an 'Id' field. You can access the id using 'payload.Id'
Note in your example you will need to remove the object-to-string to access it. It will also overwrite your payload. So you need to use an enricher if you need the same payload values in your second transform.

Submit data-table in JSF / Primefaces?

I am working on a web application using jsf/ primefaces, netbeans and tomcat.
I have a datatable with some values loaded in from another table and some editable fields. My question is, after the user has edited this table how do i submit the whole table so it can be stored in a database, in a new table?
<h:form id="form" prependId="false">
<h3>All of your Paddocks</h3>
<p:dataTable var="paddock" value="#{paddock.getfromPaddock()}" editable="true">
<p:ajax event="rowEdit" listener="#{paddock.onRowEdit}" />
<p:ajax event="rowEditCancel" listener="#{paddock.onRowCancel}" />
<p:column headerText="Id">
<h:outputText value="#{paddock.idPaddock}" />
</p:column>
<p:column headerText="Name">
<h:outputText value="#{paddock.name}" />
</p:column>
<p:column headerText="Area">
<h:outputText value="#{paddock.area}" />
</p:column>
<p:column headerText="Enter Grass Weight">
<p:cellEditor>
<f:facet name="output"><h:outputText value="0" /></f:facet>
<f:facet name="input"><p:inputText id="modelInput" value="0" style="width:100%"/></f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:32px">
<p:rowEditor />
</p:column>
</p:dataTable>
<h:commandButton value="Log" action="#{paddock.add}" />
</h:form>
Note that the only editable column is the grass column.
First of all, there are two main mistakes which may have undesired side effects:
<h:form ... prependId="false">
Never use prependId. Remove the whole attribute.
<p:dataTable var="paddock" value="#{paddock.getfromPaddock()}">
You should give var a different name than the managed bean. E.g. paddockItem.
As to the concrete question, your other mistake is here:
<p:inputText id="modelInput" value="0" />
You didn't bind the input value to the model. So JSF won't be able to update the model with the submitted values anyway.
Fix it accordingly, e.g.:
<p:inputText id="modelInput" value="#{paddockItem.grass}" />
In the submit method, it'll be right away there in the model.
You should only make absolutely sure that you aren't interacting with the database in the getter method of the <p:dataTable value>, otherwise you will be overwriting the model on every iteration round, hereby basically trashing the submitted values until the last row before the submit method is hit. The strange method name behind the data table value value="#{paddock.getfromPaddock()}" namely suggests that you're doing that. If it were a real property, the average starter would just have used value="#{paddock.fromPaddock}" or so.
See also:
How and when should I load the model from database for h:dataTable

apply payments to specific quickbooks invoice using Ruby Gem

Our ruby gem creates invoices in quickbooks, and then creates payments for the same amount and date. How do we have the payment apply to the invoice? (quickbooks online)
Please refer Payment doc.
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/030_entity_services_reference/payment
It will be through Line( and linkedTran ) attribute.
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/020_key_concepts/0700_other_topics#Line
Ex -
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2014-07-18T09:52:33.800-07:00">
<QueryResponse startPosition="1" maxResults="1">
<Payment domain="QBO" sparse="false">
<Id>6</Id>
<SyncToken>0</SyncToken>
<MetaData>
<CreateTime>2014-07-18T09:51:59-07:00</CreateTime>
<LastUpdatedTime>2014-07-18T09:51:59-07:00</LastUpdatedTime>
</MetaData>
<TxnDate>2014-07-18</TxnDate>
<CurrencyRef name="United States Dollar">USD</CurrencyRef>
<Line>
<Amount>300.00</Amount>
<LinkedTxn>
<TxnId>1</TxnId>
<TxnType>Invoice</TxnType>
</LinkedTxn>
</Line>
<CustomerRef name="Anna Ellixson">2</CustomerRef>
<DepositToAccountRef>4</DepositToAccountRef>
<TotalAmt>300.00</TotalAmt>
<UnappliedAmt>0</UnappliedAmt>
<ProcessPayment>false</ProcessPayment>
</Payment>
</QueryResponse>
</IntuitResponse>
To get the correct object structure, create an invoice in QB UI and corresponding Payment and then retrieve the Payment Object using getById(Payment) endpoint.
You can try this from ApiExplorer.
https://developer.intuit.com/apiexplorer?apiname=V3QBO
Thanks

Jasper Report (iReport) Pie Dataset from main dataset

I want to use a pie chart per group in Jasper iReport, but I don't know how to create a dataset per group.
Assume I have a table as follows:
Table users
---------
category - user - status
Then I have a the following SQL
select * from users order by category
My display has a simple group band of category with detail showing each user and their status. Ideally I would have each category group header show a pie chart with all the distinct statuses and their counts within that group. I'm at a loss as how to do this in iReport.
If I knew all the categories ahead of time I could just create a dataset for each one using the following:
select status, count(user) from user where category = <current category> group by status
I'm attempting to do this using a JRMapCollectionDataSource that resets each group and pulls the data from the rows in the group using a variable, but I'm not very familiar with the whole reset group and increment paradigm.
Any help?
You can solve this issue without programming following this steps:
sort data by category field and by user field (add sorting via iReport or adding ORDER BY clause to the query in case having deal with jdbc datasource);
add two groups: the 1st group - for category field and the 2nd group - for user field (via iReport). Note: It is not necessarily to add GROUP BY clause to the query;
add Pie Chart component to the Group Header band for the category field;
set evaluationTime and evaluationGroup properties for this pieChart.
Here is working sample for demonstrating how to build Pie Chart. In this sample I've used the csv file as datasource.
The chart shows the quantity of users for every category. I used variable usersCount for counting users in every group, but it is was possible to use built-in variable $V{userGroup_COUNT}.
Here is my jrxml file:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ...>
<field name="category" class="java.lang.Integer"/>
<field name="user" class="java.lang.String"/>
<field name="status" class="java.lang.String"/>
<sortField name="category"/>
<sortField name="user"/>
<variable name="usersCount" class="java.lang.Integer" resetType="Group" resetGroup="userGroup" calculation="Count">
<variableExpression><![CDATA[$F{user}]]></variableExpression>
<initialValueExpression><![CDATA[0]]></initialValueExpression>
</variable>
<group name="categoryGroup">
<groupExpression><![CDATA[$F{category}]]></groupExpression>
<groupHeader>
<band height="135">
<pieChart>
<chart evaluationTime="Group" evaluationGroup="categoryGroup">
<reportElement x="158" y="0" width="200" height="135"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<pieDataset>
<dataset resetType="Group" resetGroup="categoryGroup" incrementType="Group" incrementGroup="userGroup"/>
<keyExpression><![CDATA[$F{user}]]></keyExpression>
<valueExpression><![CDATA[$V{usersCount}]]></valueExpression>
<labelExpression><![CDATA[String.valueOf($V{usersCount})]]></labelExpression>
</pieDataset>
<piePlot>
<plot/>
<itemLabel/>
</piePlot>
</pieChart>
<textField>
<reportElement x="0" y="0" width="100" height="20"/>
<textElement/>
<textFieldExpression><![CDATA["Category: " + $F{category}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
</group>
<group name="userGroup">
<groupExpression><![CDATA[$F{user}]]></groupExpression>
</group>
<title>
<band height="79" splitType="Stretch"/>
</title>
</jasperReport>
Here is my csv file (data file - datasource):
category,user,status
1,user1,WORK
1,user1,HOLIDAY
1,user2,SICK
2,user1,WORK
2,user2,WORK
2,user2,HOLIDAY
2,user3,HOLIDAY
2,user4,SICK
3,user1,HOLIDAY
3,user3,HOLIDAY
3,user5,HOLIDAY
4,user1,WORK
4,user1,HOLIDAY
4,user2,SICK
4,user2,WORK
4,user2,SICK
4,user3,HOLIDAY
4,user4,HOLIDAY
4,user5,HOLIDAY
The result will be (via iReport preview):

Resources