How can I disable column auto-width feature in Clarity Datagrid? - datagrid

I need to dynamically build the columns of a Clarity Datagrid in Angular. This is how I do it:
I have an array columnsDef that holds the definition of the fields I need to show, like this:
columnsDef = [
{id:'id', label:'ID'},
{id:'client', label:'Client/Prospect'},
...
]
and another variable backlog that holds the actual data to show in the grid.
then, in my html template, I have the following code to define the columns headers and cells:
<clr-datagrid>
<clr-dg-column *ngFor="let def of columnsDef" [clrDgField]="def.id">
{{ def.label }}
</clr-dg-column>
<clr-dg-row *clrDgItems="let request of backlog" [clrDgItem]="request">
<clr-dg-cell *ngFor="let def of columnsDef">
{{ request[def.id] }}
</clr-dg-cell>
</clr-dg-row>
</clr-datagrid>
This actually "works" but the column alignment is all messed up. The values aren't below their headers and the cells width are different from row to row.
(Sorry I had to pixelize some confidential data)
How can I fix this?

Dynamic columns don't get calculated widths because of the nature of the lifecycle, the contents aren't rendered in time to know what the size is so they get a default width. If you put a [style.width.px]="100" binding on each column it will easily select that size by default instead.
Another option that I'd recommend is defining all of the columns and then dynamically hiding the ones you don't want. That means the table is fully known to the Datagrid and calculations should be better.
<clr-dg-column>
<ng-container *clrDgHideableColumn="{hidden: isColumnHidden}">
Column Name
</ng-container>
</clr-dg-column>
Some cases this might not make sense (as in sometimes columns are not meant to be available at all). In those cases I generally recommend to just define a different Datagrid for each case instead of trying to always have a dynamically built one. It makes it more explicit and declarative what the Datagrid is, and will render more cleanly.

Related

BI Publisher logic to test for existence within a grouping

I am working with a PeopleSoft BI Publisher RTF template and will be working with an XML document that has multiple rows, similar to below:
<?xml version='1.0'?>
<query numrows="3" queryname="GH3_HRS_OFFER_DS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="">
<row rownumber="1">
<A.ERNCD/>
<A.EARNS_AMT>0</A.EARNS_AMT>
<A.OFFER_COMPONENT><![CDATA[BASSAL]]></A.OFFER_COMPONENT>
</row>
<row rownumber="2">
<A.ERNCD/>
<A.EARNS_AMT>0</A.EARNS_AMT>
<A.OFFER_COMPONENT><![CDATA[PROB]]></A.OFFER_COMPONENT>
</row>
<row rownumber="3">
<A.ERNCD/>
<A.EARNS_AMT>0</A.EARNS_AMT>
<A.OFFER_COMPONENT><![CDATA[SIGNON]]></A.OFFER_COMPONENT>
</row>
</query>
What I need to do is display the 1st paragraph if the data has a row with OFFER_COMPONENT = 'PROB' and I think this is working ok as-is for the first paragraph.
However I want this to function so that either the 1st paragraph above displays, or the 2nd paragraph (<?if#inlines:A.OFFER_COMPONENT<>'PROB'?>) displays, but not both.
I don't think the way I have the 2nd paragraph coded <?if#inlines:A.OFFER_COMPONENT<>'PROB'?>) will prevent this paragraph from displaying, as once it encounters a row with a value other than 'PROB' it will display this paragraph also. I want to be able to essentially test for the existence within a group (multiple rows) whether the field A.OFFER_COMPONENT ='PROB'. If one of the rows for this field does contain 'PROB' then I do NOT want the 2nd paragraph to display.
I looked online and did not readily see a way of checking for the existence of a value of a field on multiple rows, so if anyone knows a way of doing this I would appreciated it. Thanks in advance!
So you are able to check if the first paragraph needs to be printed. Nice. Now just after you print that first paragraph, you could set a global variable to true. Check xdoxslt:set_variable.
Now you only need to print the second paragraph if the value of this global variable is false.
First, for the paragraph selection, use <?if#inlines:A.OFFER_COMPONENT='PROB'?> for the first paragraph, and <?if#inlines:A.OFFER_COMPONENT<>'PROB'?> for the second paragraph. Making sure to end each if condition with an end-if
Second, I see is that you are using a lot of for-each statements for sections that will not, or should not, contain multiple rows. For example, you have this:
...only will be $for-each0.00end per hour,...
for-each is for multiple records. You are already in the row level, so there's no need to go into the row again with a for-each. Otherwise, if you need to navigate the XML Path, just use row/A.OFFER_AMT.
for-each should be used for something like an invoice or packing list lines where you want to display the same thing multiple times, like for all of the items on the invoice or packing list.

custom rows in react-admin list view

I am using the react-admin list component and want to add a custom layout for specific rows.
Usually, each row is build by the list component using the data from the data-provider. I would like to customize specific rows based on the data of the row. These specific rows should not use the standard layout (and columns), but a specially defined one.
Here is a example, what I am looking for:
The special rows should be selected according to the data object.
Standard data object, which forms a standard row, may look like:
{
id: 127,
Reference: "OEPEE4",
author_id: 12,
...
}
The special entry may look like:
{
id: 128,
isSpecial: true,
text: "Lorem Ipsum ...",
...
}
Does anyone know how to achieve this?
Thanks!
I think the key lies in creating your custom DataGrid component's body and rows, because that way you would be able to check the value of record.isSpecial, as the record is passed to the component. Take a look at this part of the docs.
I tried playing around a bit with a custom DataGridRow (here's the sandbox), and I was able to display only the text when the record has the isSpecial property, although I think you would need to style the cells and the row. Maybe you get some ideas from it. Let me know if it helps.

How can I change column headers in tables/pivot tables in icCube reporting v6?

Is it possible to change the column headers of tables/pivot tables? By default they are named as the hierarchy/measure.
You can use icCube Table's Cell Renderers to do that.
Cell renderers is a powerful feature of icCube tables, that provides a bunch of opportunities to configure look & feel of your tables.
It can be found under "Data Render Options" category of widget options.
Several Cell Renderers
If you have static order of columns in your table you can create cell renderers for each column bound by it's index:
First column:
Second column:
One Cell Renderer / Javascript Way
This is a dynamic solution and doesn't depend on columns order.
You might want to use "Top Header Text" field to overwrite header label as shown in the picture below:
In this case I've created an alias for header labels with this peace of javascript code:
This solution an code could be expanded to handle as many columns as you need.
P.S.
"Top Header Text" field's expression value suitable for your case:
var header = context.columnLabel()
switch(header){
case 'formatted_date_hierarchy': return 'Date';
case 'product_hierarchy': return 'Product';
default: return header;
}
UPDATE
Here is a Demo Report with first solution.

How to create a grid to reconfigure grid columns on the fly

I have a grid with 10 columns, and another with over 60. I want to offer a view of these grids where any column or number of columns can be selected to remain visible. Then submit a request to hide all of the remaining 'UN-selected' grid columns, leaving the selected columns viewable.
End-users need to have a mechanism where they can choose which column(s) to view and the remaining columns will be hidden temporarily from view. I know that I can choose each column from the context menu to hide each column, but if I have a grid with multiple columns it can be quite difficult to select each column to hide. I would like to create a mechanism where users can select which columns they want to 'view' and allow the remaining columns to hide.
I believe that grid reconfigure may be the way to go, but there are no real examples showing how I might select the columns to allow viewable "on-the-fly", and then reconfigure the grid based on the new column model.
There are a couple of ways you could approach this:
One way would be to loop through the columns and call hide() method on those you wish to hide.
For a large number of columns it might be better to use reconfigure method. using reconfigure with the first paremeter undefined you get to reuse the store that was originally configured:
reconfigure( undefined, myColumns )

Flex 4 How do I access a specific cell by index?

I would like to edit a cell by the row and column indexes so essentially do the following:
advDataGrid[2][3] = "Dogs"
so that I am setting the data grid row 2 and column 3 to Dogs. I cannot for the life of me figure out how to do this!
Side note: I need this because I am trying to allow the user to copy a section of an excel file to a section of an AdvancedDataGrid like Google Docs does. I am using this idea to do it: http://mannu.livejournal.com/348299.html
Thanks! Any help will be greatly appreciated!
In general you want to operate on the dataProvider rather than the presentation (AdvancedDataGrid). So in your case, I would get the item associated with the specified row from your dataProvider and modify whichever element is specified to "Dogs". So something like this: adg.dataProvider[row].someColumnData = "Dogs"
EDIT: "someColumnData" refers to whatever property you have set for the column to display. So when you defined your AdvancedDataGrid's columns, you set the 4th column to use the "someColumnData" property of the items in your dataProvider, and you want to change the value in the 4th column, then you'd set it as described above. Hope that clarifies things.
Flex components are data driven, so you should modify the data provider of the grid.
What if you want to edit specific individual cells, eg I want to to keep running totals of some cells in other cells, IE: as a user edits I update whole columns.
Surely their must be a way to walk the array and get Column4.row6 = something.

Resources