Grouping and Sorting in RadGid - sorting

I have a issue need to resolve.
How to group Data on Radgrid but no sort. Radgri only group, no sort. Because if Radgrid sort , data will incorrect
Please help me to resolve it
Thank all so much

Set the allowsorting property to false.
<telerik:radgrid id="RadGrid1" runat="server" allowsorting="False">
Also, if you need to know how to group data, use a GridCalculatedColumn:
<telerik:GridCalculatedColumn UniqueName="Name" HeaderText="Name"
DataFields="FirstName, LastName"
Expression="{0} + ' ' + {1}">
</telerik:GridCalculatedColumn>

Related

Sales Order Grid issue in Magento 2.4.2: Column not found

On admin in Sales Order Grid, I am getting the following error. Please guide on this:
Column not found: 1054 Unknown column 'allocated_sources' in 'order clause', query was: SELECT `main_table`.*, group_concat(sales_order_item.sku SEPARATOR ", ") AS `skus`, group_concat(sales_order_item.name SEPARATOR ",") AS `names`, `braintree_transaction_details`.`transaction_source` FROM `sales_order_grid` AS `main_table`
LEFT JOIN `sales_order_item` ON sales_order_item.order_id = main_table.entity_id
LEFT JOIN `braintree_transaction_details` ON braintree_transaction_details.order_id = main_table.entity_id GROUP BY `main_table`.`entity_id` ORDER BY allocated_sources ASC
I have one extra column in grid i.e. Allocated Sources.
I got the solution for the same.
Just override the module sales order grid & add the following code. Upgrade your module & Flush the cache. It will work.
1 - Create a new module with Magento standards
2 - Override file with this content view/adminhtml/ui_component/sales_order_grid.xml
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="allocated_sources"
class="Magento\InventoryShippingAdminUi\Ui\Component\Listing\Column\AllocatedSources"
component="Magento_InventoryShippingAdminUi/js/order/grid/cell/allocated-sources">
<settings>
<filter>false</filter>
<label translate="true">Allocated sources</label>
<sortable>false</sortable>
</settings>
</column>
</columns>
</listing>
Your problem will be solved.
Thanks,
Rashi
Please check the "allocated_sources" column in your database. I guess it hasn't been created yet or you are joining the wrong table.

Primefaces lazytable sorting change first sorting order

is there any way to allow, after the first request to sort a particular column, not to be listed first in ascending order, but first in descending order?
description:
If I need to sort the column in descending order, it is necessary to first click on the column in ascending order and only then reload the table with the sorted data as I require.
One not entirely nice solution that I use now is in the case of columns, where I require the reverse order, I simply swap the meaning ascending/descending when querying the DB. But the table does not show graphically correctly the arrow above the table in which direction I am sorting the data and it is necessary to intervene for the columns in CSS.
Is there a more elegant option?
Sorry for my easy English and thanks for any advice,
Venca.
As #Melloware pointed in comment datatable has fields sortBy and sortOrder which can be used for sorting.
See example:
<p:dataTable id="txnTable"
value="#{chTransactionsForm.transactions}" var="res"
sortMode="single" sortBy="#{res.activityDate}" sortOrder="DESCENDING"
rows="#{referenceData.recordsPerPage}" rowKey="#{res._lineNumber}"
lazy="true" resizableColumns="true"
paginator="true" paginatorPosition="bottom" paginatorAlwaysVisible="false"
paginatorTemplate="#{referenceData.paginatorTemplate}">
<p:column id="activityDate" headerText="#{msg.transDate}"
sortBy="#{res.activityDate}" width="120">
<h:outputText value="#{res.activityDate}">
<f:convertDateTime timeZone="#{referenceData.timezone}"
pattern="MMM dd, yyyy HH:mm" />
</h:outputText>
</p:column>
...

PrimeNG datatable performance very slow in case there is a lot of data

I use PrimeNG datatable. In case the table contains many rows, the datatable's performance works very slow.
This is my html:
<p-dataTable #dt [rowTrackBy]="rowTrackBy" [emptyMessage]="'TABLE.EMPTY_MESSAGE'|translate" #dt [rows]="rows" [paginator]="paginator"
lazy="false" [pageLinks]="3" scrollable="true"[editable]="editable" [styleClass]="paginator?'paginator': enableFilter?'scroll filter-table':'scroll'"
[globalFilter]="gb"[value]="displayList" resizableColumns="true" [(selection)]="selectedItem"
(onRowDblclick)="importButton?'':onRowDblclick($event.data)"[expandableRows]="showExpander" [expandedRows]="expandedRows"
(onRowSelect)="onrowSelect($event)" (onRowClick)="selectRow($event);onrowSelect($event)" (onRowUnselect)="onRowUnSelect($event)"[rowStyleClass]="rowStyleClass"
[selectionMode]="(enableSelect&&!showSelectColumn)?(multiSelect?'multiple':'single'):''" [metaKeySelection]="false"
(onHeaderCheckboxToggle)="onHeaderCheckboxToggle($event)">

sortBy an EL Expression in primefaces

Is it possible to use sortBy with an EL expression containing multiple values in Primefaces , if it is how or how can i approach this.
Problem:
I Need to sory the table by latest date. There are two columns one with created date and another with updated date. if updated exist i need to use it to sort.
I looked at JSF 2 , Primefaces 4.0. p:dataTable sorting using complex sortBy expression
and PrimeFaces dataTable sorting not working but neither does what i need. second one was just in google search
Example
<p:column headerText="Last Logged in Date" sortBy="#{login.lastUpdated ne null ? login.lastUpdated : login.createdDate }">
<h:outputText value="#{login.lastUpdated ne null ? login.lastUpdated : login.createdDate }" >
<f:convertDateTime pattern="yyyy/MM/dd HH:mm" />
</h:outputText>
</p:column>
Any Advice would be appreciated.
Thanks in advance.

Using FetchXML in CRM 2011

I am using FetchXML and I am grouping and using count for two of the entities but the rest of the entities I don't need grouped I just need the data to be pulled down. For example this is my code:
string groupby1 = #"
<fetch distinct='false' mapping='logical' aggregate='true'>
<entity name='opportunity'>
<attribute name='name' alias='opportunity_count' aggregate='countcolumn' />
<attribute name='ownerid' alias='ownerid' groupby='true' />
<attribute name='createdon' alias='createdon' />
<attribute name='customerid' alias='customerid' />
</entity>
</fetch>";
EntityCollection groupby1_result = orgProxy.RetrieveMultiple(new FetchExpression(groupby1));
foreach (var c in groupby1_result.Entities)
{
Int32 count = (Int32)((AliasedValue)c["opportunity_count"]).Value;
string OwnerID = ((EntityReference)((AliasedValue)c["ownerid"]).Value).Name;
DateTime dtCreatedOn = ((DateTime)((AliasedValue)c["createdon"]).Value);
string CustomerName = ((EntityReference)((AliasedValue)c["customerid"]).Value).Name;
}
But I get this error:
EXCEPTION: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: An attribute can not be requested when an aggregate operation has been specified and its neither groupby nor aggregate. NodeXml : (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).
How do you use aggregates on some values and not others?
The error message is giving you the answer - this isn't possible with FetchXML. You'll need to make two FetchXML calls; one for your aggregates and one for your data.
So, there are a few things going on here. The problem isn't so much that your query is not achievable with FetchXML as it is it's not achievable in any query language, including SQL. The SQL of your FetchXML above is as follows:
SELECT ownerID, createdon, customerid
FROM dbo.Opportunity
GROUP BY ownerID
If you try to run this SQL against your database, you'd get the standard Column 'dbo.Opportunity.CreatedOn' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. error, which is exactly what your exception is trying to tell you. To solve this, you need to also group by every non-aggregated column (in this case, createdon and customerid) by including the groupby='true' attribute in each respective attribute element.
Secondly, grouping by the create date of each opportunity is more or less a fruitless grouping, as opportunities are generally created on different datetimes, so this grouping would just return the whole table. Microsoft rightly recognizes this, so if you fix the grouping issue above, you will encounter another exception related to the datetime column. If you continue reading the article I'd previously shared, there is an example that address the different ways you can group by different date intervals (year, month, quarter, etc.) using the dategrouping attribute.
But, I get the feeling that even after fixing the general grouping issues, and then the dategrouping issue, the result set might still not be what you want. If it's not, it might help to post an example of a result set that you'd expect to see and then address whether FetchXML has the power to deliver that set to you.

Resources