How to apply rowspan and colspan to cell in Dhtmlx Grid view - dhtmlx

My dhtmlxgrid view looks like the below mentioned.Using Json data.
code desc Qtytype w1 w2
Part A Part A desc Demand 100 200
issued 150 100
stock 200 200
F/C 100 250
Part B Part B desc Demand 100 200
issued 200 100
stock 300 200
F/C 100 250
I want to apply the rowsapn and colspan cell level.Kindly anyone suggest how to apply span in the cell level to make the view aboved.Thanks in advance.

There are two ways
a) after data loading you can use js api to make necessary col and rowspans
grid.load("some.url", function(){
grid.setRowspan(1,0,4) //1 - id of row
grid.setRowspan(1,1,4) //1 - id of row
});
b) you can define rowspans directly in data, in case of xml it will be
<row id="1"><cell rowspan="4">Part A</cell>
as far as I know the similar syntax must be available for json, but it is buggy in current version (3.5) and works for xml only.

After Data loaded you can apply like this
dfGrid.forEachRow(function(id){
if((id)%4==0)
{
dfGrid.forEachCell(id,function(cellObj,ind){
if(ind <= 3){
dfGrid.setRowspan(id,ind,4);
}
});
}
});
4 denotes how many row you need to apply.
3 denotes how many coloumn rowspan should be applied.
Note -- Id should be starts from the multiple of 4. based on the no of row the value of id varied ex.3 means id should start with multiple of 3.
Thank you.

Related

Dynamics crm + Plugin code to store sum formula across a entity collection

I have the below requirement to be implemented in a plugin code on an Entity say 'Entity A'-
Below is the data in 'Entity A'
Record 1 with field values
Price = 100
Quantity = 4
Record 2 with field values
Price = 200
Quantity = 2
I need to do 2 things
Add the values of the fields and update it in a new record
Store the Addition Formula in a different config entity
Example shown below -
Record 3
Price
Price Value = 300
Formula Value = 100 + 200
Quantity
Quantity Value = 6
Formula Value = 4 + 2
Entity A has a button named "Perform Addition" and once clicked this will trigger the plugin code.
Below is the code that i have tried -
AttributeList is the list of fields i need to perform sum on. All fields are decimal
Entity EntityA = new EntityA();
EntityA.Id = new Guid({"Guid String"});
var sourceEntityDataList = service.RetrieveMultiple(new FetchExpression(fetchXml)).Entities;
foreach (var value in AttributeList)
{
EntityA[value]= sourceEntityDataList.Sum(e => e.Contains(value) ? e.GetAttributeValue<Decimal>(value) : 0);
}
service.Update(EntityA);
I would like to know if there is a way through linq I can store the formula without looping?
and if not how can I achieve this?
Any help would be appreciated.
Here are some thoughts:
It's interesting that you're calculating values from multiple records and populating the result onto a sibling record rather than a parent record. This is different than a typical "rollup" calculation.
Dynamics uses the SQL sequential GUID generator to generate its ids. If you're generating GUIDs outside of Dynamics, you might want to look into leveraging the same logic.
Here's an example of how you might refactor your code with LINQ:
var target = new Entity("entitya", new Guid("guid"));
var entities = service.RetrieveMultiple(new FetchExpression(fetchXml)).Entities.ToList();
attributes.ForEach(a => target[a] = entities.Sum(e => e.GetAttributeValue<Decimal>(a));
service.Update(target);
The GetAttributeValue<Decimal>() method defaults to 0, so we can skip the Contains call.
As far as storing the formula on a config entities goes, if you're looking for the capability to store and use any formula, you'll need a full expression parser, along the lines of this calculator example.
Whether you'll be able to do the Reflection required in a sandboxed plugin is another question.
If, however, you have a few set formulas, you can code them all into the plugin and determine which to use at runtime based on the entities' properties and/or config data.

In Pentaho Data Integration can I output conditionally?

I need to output a different CSV file every 100 rows. For example, if there are 305 rows in a stream, I'd need to output a CSV for rows one through 100, 101 to 200, 201 to 300, and 301 to 305.
I got a column for the last row number, and built a page number variable which increments every 100 rows. I then tried searching online since I can't yet conceptualize a solution.
var numberOfInvoicePages = Math.ceil(Number(lastRow) / 300);
if(rowNumber % 300 == 0){
pageNumber += 1;
}
I expect to get a CSV which says ${baseTitle} ${pageNumber} for each page, and for the actual results I don't yet know how to build this.
In the Text File output step, you can adjust on how many rows the output will split to another file, under the option 'Split ever ... rows'.

How to achieve dimensional charting on large dataset?

I have successfully used combination of crossfilter, dc, d3 to build multivariate charts for smaller datasets.
My current system caters to 1.5 million txns a day and I want to use the above combination to show dimensional charts on this big sized data (spanned over 6 months). I cannot push this sized data to the frontend for obvious reasons.
The txn data has seconds level granularity but this level of granularity is not required in the visualization. If txn data can be rolled up to a granularity of a day at the backend and push the day based aggregation to the front end then it can drastically reduce the IO traffic and size of the data given to the crossfilter,dc and then dc can show its visualization magic.
Taking forward the above idea -> I decided to reduce the size of the data by reducing the granularity of the timeseries data from millseconds to day by pre-aggregating the data from various dimensions using the below GROUP BY query (this is similar to the stuff done by crossfilter but at the frontend)
SELECT TRUNC(DATELOGGED) AS DTLOGGED, CODE, ACTION, COUNT(*) AS
TXNCOUNT, GROUPING_ID(TRUNC(DATELOGGED),CODE, ACTION) AS grouping_id
FROM AAAA GROUP BY GROUPING SETS(TRUNC(DATELOGGED),
(TRUNC(DATELOGGED),CURR_CODE), (TRUNC(DATELOGGED),ACTION));
Sample output of these rows:
Tuples/Rows in which aggregation is done by (TRUNC(DATELOGGED),CODE) will have a common grouping_id 1 and by (TRUNC(DATELOGGED),ACTION) will have a common grouping_id 2
//group by DTLOGGED, CODE
{"DTLOGGED":"2013-08-03T07:00:00.000Z","CODE":"144","ACTION":"", "TXNCOUNT":69,"GROUPING_ID":1},
{"DTLOGGED":"2013-08-03T07:00:00.000Z","CODE":"376","ACTION":"", "TXNCOUNT":20,"GROUPING_ID":1},
{"DTLOGGED":"2013-08-04T07:00:00.000Z","CODE":"144","ACTION":"", "TXNCOUNT":254,"GROUPING_ID":1},
{"DTLOGGED":"2013-08-04T07:00:00.000Z","CODE":"376","ACTION":"", "TXNCOUNT":961,"GROUPING_ID":1},
//group by DTLOGGED, ACTION
{"DTLOGGED":"2013-08-03T07:00:00.000Z","CODE":"","ACTION":"ENROLLED_PURCHASE", "TXNCOUNT":373600,"GROUPING_ID":2},
{"DTLOGGED":"2013-08-03T07:00:00.000Z","CODE":"","ACTION":"UNENROLLED_PURCHASE", "TXNCOUNT":48978,"GROUPING_ID":2},
{"DTLOGGED":"2013-08-04T07:00:00.000Z","CODE":"","ACTION":"ENROLLED_PURCHASE", "TXNCOUNT":402311,"GROUPING_ID":2},
{"DTLOGGED":"2013-08-04T07:00:00.000Z","CODE":"","ACTION":"UNENROLLED_PURCHASE", "TXNCOUNT":54910,"GROUPING_ID":2},
//group by DTLOGGED
{"DTLOGGED":"2013-08-03T07:00:00.000Z","CODE":"","ACTION":"", "TXNCOUNT":460732,"GROUPING_ID":3},
{"DTLOGGED":"2013-08-04T07:00:00.000Z","CODE":"","ACTION":"", "TXNCOUNT":496060,"GROUPING_ID":3}];
Questions:
These rows are are dis-joined i.e. not like usual rows where each row will have valid values for CODE and ACTION in a single row.
After a selection is made in one of the graphs, the redrawing effect either removes the other graphs or shows no data on them.
Please give me any troubleshooting help or suggest better ways to solve this?
http://jsfiddle.net/universallocalhost/5qJjT/3/
So there are a couple things going on in this question, so I'll try to separate them:
Crossfilter works with tidy data
http://vita.had.co.nz/papers/tidy-data.pdf
This means that you will need to come up with a naive method of filling in the nulls you're seeing (or if need be, in your initial query of the data, omit the nulled values. If you want to get really fancy, you could even infer the null values based off of other data. Whatever your solution, you need to make your data tidy prior to putting it into crossfilter.
Groups and Filtering Operations
txnVolByCurrcode = txnByCurrcode.group().reduceSum(function(d) {
if(d.GROUPING_ID ===1) {
return d.TXNCOUNT;
} else {
return 0;
}
});
This is a filtering operation done on the reduction. This is something that you should separate. Allow that filtering to occur elsewhere (either in the visual, crossfilter itself, or in the query on the data).
This means your reduceSum's become:
var txnVolByCurrcode = txnByCurrcode.group().reduceSum(function(d) {
return d.TXNCOUNT;
});
And if you would like the user to select which group to display:
var groupId = cfdata.dimension(function(d) { return d.GROUPING_ID; });
var groupIdGroup = groupId.group(); // this is an interesting name
dc.pieChart("#group-chart")
.width(250)
.height(250)
.radius(125)
.innerRadius(50)
.transitionDuration(750)
.dimension(groupId)
.group(groupIdGroup)
.renderLabel(true);
For an example of this working:
http://jsfiddle.net/b67pX/

JqGrid gives wrong result of number of records,number of pages and rowNum when used filter toolbar

In my app, I am using JQGrid to render the data in Grid.
In this case, my Grid is set to loadonce:true and It also provides filter toolbar facility.
My problem is, I am getting wrong count of total number of pages,total number of records and rowNum of the grid when i have used filter toolbar.
For example : My grid is having total 14 records and rowNum = 5. So there are total 3 pages as displayed in below image.
Now the code below works fine for me in normal case (case in which I have not used filters toolbar).
var records = $('#list10').getGridParam('records');
var rowNum = $('#list10').getGridParam('rowNum');
var pageCount = Math.ceil( parseInt(records) / parseInt(rowNum));
But When I used filters the above written code is not giving me updated result. Consider the image below for example ..
Here for this case the above mentioned code gives me same result as .. total pages =3 , total number of rows =14 and rowNum = 5.
Can anyone suggest me that How can I retrieve the updated value of page,total,records,rowNum when I have used filter toolbar ??

DHTMLX Freeze grid is not working in IE

When freeze applied to dhtmlxgrid the header repeating based on the split value.
Before applying split
code desc Qtytype w1 w2
Part A Part A desc Demand 100 200
After apply split the grid looks like in IE
code desc Qtytype code desc Qtytype w1 w2
Part A Part A desc Demand 100 200 300 400 500
Kindly advise how to arrest the header repeat in IE.Thank You
Using SplitAt before init. And try to Load the Header and Detail dhtmlx ajax synchron call.,

Resources