Slickgrid Sorting only parent rows - sorting

I have a data view which will be rendered something like below,
item1
item2
item3
item4
Where, item 1 and 4 are parents, is it possible to sort only these two items? will the subitems (2 and 3) come under its parent even after sorting?
Please clarify.

You can do that by implementing custom onSortHandler. Here is how I'm doing it:
Create your sorting function
function customOnSortHandler_1(value1, value2, sortAsc) {...}
When specifying column metadata on the page have an attribute added
..., onSortHandler:customOnSortHandler_1, ...
subscribe this handler to onSort event
And in you customOnSortHandler you can do aaaaanything you want :)

Related

ag-grid modify Row Group's Header name

I'm using ag-grid to display a table which has a Row Grouping.
The column that I group by is invisible since its value holds no meaning.
So for example, I will have the following (fully collapsed) table:
---------------------------------
| H1 H2 H3 |
----------------------------------
| > groupId1 (1) |
----------------------------------
| > groupId2 (5) |
----------------------------------
As you see the grouping is done by user-unfriendly ID which is not reflected at all in the Column Definitions. I would like to change groupId1 / groupId2 to a user-friendly text that is assigned dynamically according to the content of the group rows.
I am using React.
I am using ag-Grids examples as a starting point, the following example embodies the problem I'm facing: (eg: https://plnkr.co/edit/VM59gScPD55PhX4y4JBj?p=preview)
It has row grouping
The grouping is done by a column that is invisible (country)
I would like to change the country name dynamically into a different value that's derived from the values of the inner row.
Thanks for your time. :)
You can also rename the rowGroup header of ag-grid by using this simple prop
autoGroupColumnDef
<AgGridReact
columnDefs={columnDefs}
rowData={rowData}
autoGroupColumnDef={{
headerName: 'Name'
}}
/>
A colleague helped me at the end, his solution was:
valueFormatter: ({ value, data }) => 'something ' + value
inside the colDef of my group, and the value to be displayed as the header is sent inside 'data'.
He said that cellRenderer is an overkill for a simple task like this.
You can pass additional params about group cell renderer and customize it like this -
colDef = {
// set the cell renderer to 'group'
cellRenderer:'agGroupCellRenderer',
// provide extra params to the cellRenderer
cellRendererParams: {
innerRenderer: myInnerRenderer, // provide an inner renderer
}
...
};
You should be then able to display any text based on custom logic using the myInnerRenderer implementation.
Here is an example from ag-grid docs. Check the Group Renderer C implementation

join two tables in linq with special conditions

I hope one can help me, I am new in linq,
I have 2 tables name tblcart and tblorderdetail:
I just show some fields in these two tables to show whats my problem:
tblCart:
ID,
CartID,
Barcode,
and tblOrderDetail:
ID,
CartID,
IsCompleted
Barcode
when someone save an order, before he confirms his request,one row temporarily enter into the tblCart,
then if he or she confirms his request another row will be inserted into the tblOrderDetail ,
Now I wanna not to show the rows that is inserted into tblOrderDetailed(showing just temporarily rows which there is in tblCart),
In another words, if there is rows in tblCart with cartID=1 and at the same time there is the same row with CartID= 1 in tblOrderDetail, then I dont want that Row.
All in all, Just the rows that there isnt in tblOrderDetail, and the field to realize this is CartID,
I should mention that I make Iscompleted=true, and with that either we can exclude the rows we do not want,
I did this:
var cartItems = context.tblCarts
.Join(context.tblSiteOrderDetails,
w => w.CartID,
orderDetail => orderDetail.cartID,
(w,orderDetail) => new{w,orderDetail})
.Where(a=>a.orderDetail.cartID !=a.w.CartID)
.ToList()
however it doesn't work.
one example:
tblCart:
ID=1
CartID=1213
Barcode=4567
ID=2
CartID=1214
Barcode=4567
ID=3
CartID=1215
Barcode=6576
tblOrderDetail:
ID=2
CartID=1213
Barcode=4567
IsCompleted=true
with these data it should just show the last two Row in tblCart, I mean
ID=2
CartID=1214
Barcode=4567
ID=3
CartID=1215
Barcode=6576
This sounds like a case for WHERE NOT EXISTS in sql.
roughly translated this should be something like this in LINQ:
var cartItems = context.tblCarts.Where(crt => !context.tblSiteOrderDetails.Any(od => od.CartID == crt.cartID));
If you have a navigation property on cart to reference details (I'll assume it's called Details), then:
var results=context.tblCarts.Where(c=>!c.Details.Any(d=>d.IsCompleted));

Error 'sqlPrepareWithOptions' status='-9' when I insert data item

I have two data items :
1)
sum(If ([DEV].[STATUS] IN ('Success','Failure'))
THEN ([DEV.[AMT])
ELSE (0))
2)
sum(If ([DEV].[STATUS] IN ('Success','Failure'))
THEN (1)
ELSE (0))
When I try to use the first item in a list cell I get an error 'sqlPrepareWithOptions' status='-9' / group function is not allowed here
The second is working fine in the same scenario.
Thanks!
I set the aggregate function to none. The problem was in my structure. I was adding the data item to list cell under list footer. When I added the item to list cell under list page footer, I was able to run the report successfully.

Hadoop Pig ordered results; find order position?

I want to sort my pig results, and then be able to determine where certain items are in my ordered results. Example:
mydata = LOAD 'mydata.txt' AS (label:chararray, rank_score:float);
ranked_data = ORDER mydata BY rank_score DESC;
ranked_positions = FOREACH ranked_data GENERATE label, AUTO_INCREMENT_ID;
results = FILTER ranked_data BY label = 'item1' OR label='item2';
DUMP results;
AUTO_INCREMENT_ID would auto-increment in my perfect world. Given how mappers/reducers are independent from each other, I'm guessing Pig/Hadoop may not support this. If not, can you think of another way to generate my end result?
Example input:
item1 34.33
item2 48.39
item3 93.3
Desired output:
item1 3
item2 2
If you set parallelism of ORDER to 1, you can just do auto-increment yourself in a udf; of course, that would have the potentially undesired effect of only using 1 reducer to do your sorting.
(Also, I am not sure how you got your example output -- the input seems to be already ordered, so item1 should have id 1 and item 2 should have id 2, right? did you mean to order by rank_score desc?)

Fetched Property in XCode Data Model Editor for minimum value

How do I add a Fetched Property in XCode's Data Model Editor for minimum value of one attribute??
My model:
Model http://www.freeimagehosting.net/uploads/b48853070e.png
Item (name, note, storedItem)
StoredItem (price, item)
Item 1 ---> N StoredITem (1->N Relationship)
I want that Item has a fetched property named minPrice and its value is the minimum value setted for price in the storedItems.
Example:
Item1 (banana, storedItem1 ... storedItem4, 10)
StoredItem1 (10,item1)
StoredItem2 (15,item1)
StoredItem3 (30,item1)
StoredItem4 (54,item1)
What do I put in Destination?? StoredItem?
Fetched Property in Data Model Editor http://www.freeimagehosting.net/uploads/2a68de007d.png
And what do I put in Expression??
Expression in Data Model Editor http://www.freeimagehosting.net/uploads/766ab9af6f.png
The destination is the type of entity you want back.
It sounds like you want a StoredItem back, since that has a price on it.
What I think you want is a fetched property on Item called minPrice, with this expression:
"#min.storedItems.price"

Resources