ExtJS and simple grid panel - extjs

I have a simple grid without direct connection with any database table. Just days of mounth in raws and persons in columns (let's say 31 x 20). In init procedures I read data from some tables, calculate and write them to this grid. Then I have to calculate lot of indexes, make some summs by raws, columns and part of them. Just statistics.
There's no problem with read from grid cells, this is very quick. I have a problem with writing data to the cells. E.g. procedure to fill this grid is the following:
days = Ext.getStore('StoreDays').getRange();
employees = Ext.getStore('StoreTeam').getRange();
Ext.each(days, function (day) {
Ext.each(persons, function (guy) {
tmp = day.get('from');
day.set('start_' + persons.data.prs_numer, start);
... and 4 additional SET operations to grid cells
});
});
And this procedure work more then 3 minutes!!! I don't know why and how to write good code to write this data normally. Be so kind and prompt me HOW!
Additionally I can't refresh e.g. every single raw after raw settings as I want.
Would you be so kind as to prompt me?

A cell update could mean the grid needs to refresh itself, so it does that 31x20x5 (31 rows, 20 columns, 5 times per cell) times!
Instead, do this:
store.suspendEvents();
// Do your update
store.resumeEvents();
grid.getView().refresh();

Related

Anylogic: How to create plot from database table?

In my Anylogic model I succesfully create plots of datasets that count the number of trucks arriving from terminals each hour in my simulation. Now, I want to add the actual/"observed" number of trucks arriving at a terminal, to compare my simulation to these numbers. I added these numbers in a database table (see picture below). Is there a simple way of adding this data to the plot?
I tried it by creating a variable that reads the database table for every hour and adding that to a dataset (like can be seen in the pictures below), but this did not work unfortunately (the plot was empty).
Maybe simply delete the variable and fill the dataset at the start of the model by looping through the dbase table data. Use the dbase query wizard to create a for-loop. Something like this should work:
int numEntries = (int) selectFrom(observed_arrivals).count();
DataSet myDataSet = new DataSet(numEntries);
List<Tuple> rows = selectFrom(observed_arrivals).list();
for (Tuple
row : rows) {
myDataSet.add(row.get( observed_arrivals.hour ), row.get( observed_arrivals.terminal_a ));
}
myChart.addDataSet(myDataSet);
You don't explain why it "didn't work" (what errors/problems did you get?), nor where you defined these elements.
(1) Since you want both observed (empirical) and simulated arrivals per terminal, datasets for each should be in the Terminal agent. And then the replicated plot (in Main) can have two data entries referring to data sets terminals(index).observedArrivals and terminals(index).simulatedArrivals or whatever you name them.
(2) Using getHourOfDay to add to the observed dataset is wrong because that just returns 0-23 (i.e., the hour in the current day for the current model date). Your database table looks like it has hours since model start, so you just want time(HOUR) to get the model time in elapsed hours (irrespective of what the model time unit is). Or possibly time(HOUR) - 1 if you only want to update the empirical arrivals for the hour at the end of that hour (i.e., at the same time that you updated the simulated arrivals).
(3) Using a Variable to get the database value each hour doesn't work because a variable's initial value is only evaluated once at model initialisation. You want an hourly cyclic Event in Terminal instead which adds the relevant row's value. (You need to use the Insert Database Query wizard to generate the relevant Java code for the query you need in the event's action.)
(4) Because you have a database table with specifically-named columns for each terminal (columns terminal_a and presumably terminal_b etc.) that makes it slightly more awkward. (This isn't proper relational table design where, instead of 4 columns for the 4 terminals, you'd instead have two columns for terminal_id and observed_value with a row for each time period and terminal combination.)
So your database query expression (in your Terminal agents) will need to use the SQL format (not the QueryDSL format) so that you can 'stitch in' the correct column name into the SQL.

How to get the number of filtered rows in ag-grid without using in memory row model?

I am using ag-grid to display data. There are two tabs for current data and archived data. Above the grid for both tabs, in the title bar, there is a filter that filters the free text. The label of that filter shows the filtered rows/total number of rows.
In the archived tab, there is an additional filter that selects the data from past months. The filtered row count gets bigger than the actual number of rows when you quickly switch to:
Last Year
Last 6 Months
Last 3 Months
and then switch between tabs.
I think it is the in memory row model that is causing this issue.
I tried these two to get filtered rows
this.selectedRows = this.gridOptions.api.getModel().getRowCount();
this.selectedRows = this.gridOptions.api.getModel().rootNode.childrenAfterFilter.length;
I was just wondering is there any other way of doing it without using the in memory row model. Any help would be greatly appreciated.
Thanks a lot.
For future reference:
The code below is fine.
this.selectedRows = this.gridOptions.api.getModel().getRowCount();
The were some timing issues and I fixed this with resetting the row data by
this.gridOptions.api.setRowData([]);
this.gridOptions.api.setRowData(data);

Dataset from a Dataset in SSRS

I laid out the report, and I do a query that returns 30+ rows for a given period of time. One for each workflow. Now, I want to take that dataset (so the query only runs once) and define 6 datasets from it that filter it based on a single selected row. I will populate 8 boxes on the form for each of those datasets.
It appears that when you create a new dataset, it wants to go back to the datasource and ask you about all the data from that one again.
I was able to create a dataset that is a filtered view of the query and figured I could live with creating 6 datasets that ran the query each time filtering it differently each time. So, I need to do a 'copy' on the dataset and 'paste' it back in as a new dataset that is the same as the other one except with a new name.
I also need to set the default values for the Start/End date to be the 1st of last quarter, and the first day of this quarter. Is there a way to create calculated default values or do I need to do a query to return that?
if you are using table objects to create your report. you could use just 1 data set and add your filters to the table accordingly. just go to tablix properties>> filters tab.
for default values you can create expressions like for the first day of the current quarter:
=switch(DatePart(DateInterval.Quarter,today()) = 1, cstr(year(today))+"-01-01",
DatePart(DateInterval.Quarter,today()) = 2, cstr(year(today))+"-04-01",
DatePart(DateInterval.Quarter,today()) = 3, cstr(year(today))+"-07-01",
DatePart(DateInterval.Quarter,today()) = 4, cstr(year(today))+"-10-01")

Taking too long to retrieve and display the result in the telerik grid.

I have a MVC application in which I need to display the data from 3 tables. I am using entity model for it. Out of these, in 2 I have made the association:users and payment table.
And 3rd table month_<monthid> is created every month to store the users to whom the magazine is sent. The table name month_<monthid> is generated dynamically by selecting the month so in order to fetch the data I have used ExeuteStoreQuery. For small amount of data the listing is fast but for large amount it is very slow.
Now I have created a class to bind to grid which will include all the fields from the 3 tables to display.
But here when I am getting the large volume of data about 12000 then it is taking about 30 min to go through the loop and assigning the data to the class object and then adding to the list of the result which is finally binded to telerik grid.
I am hereby attaching the sample code using a link. Is there any direct way to bind the query result of joined tables to grid instead of going through the loop and preparing the list for the model class I think that will save time.
The code block of preparing the list using the Executestorequery is under the function GetuserList().
foreach (var r in result)
{
Result objresult = new Result();
var paymentresult = from sub in dtpayment.AsEnumerable() where sub.Field<int>("user_id") == r.user_id select sub;
if (paymentresult.Count() > 0)
{
objresult.amount_paid = paymentresult.FirstOrDefault().Field<decimal>("amount_paid");
objresult.magzine_id = paymentresult.FirstOrDefault().Field<int>("magzine_id");
}
objresult.address=r.address;
objresult.email=r.email;
objresult.name=r.name;
objresult.user_id=r.user_id;
objresult.month= smonth;
lstresult.Add(objresult);
}
This code block of for loop is taking very time where I am using ExceuteStoreQuery.
But I have observed that simply by joining the users and payment table using LINQ query to get all the 12000 records i.e no involvement of month table the result is appearing faster.
So,can you suggest any way to improve the performance of my application?
Also include the database structure with the sample code.
Below is the link to sample
http://sampletestone.s3.amazonaws.com/magzine.7z?AWSAccessKeyId=AKIAINHDRCMKC5GUSNFA&Expires=1303583399&Signature=8o8Wn6UNjbEl3dIyipAX9xH29Hg%3D
supriya
Nobody in the world wants to see 12,000 records. You should look at implementing paging & searching functionality.

how to string a data from uitable that been input by the user?

I'm trying to build a matrix form by creating a uitable in GUIDE. So I want the user to enter data into the table and I want to use the data at the pushbutton. But I dunno how to string the data from the table to the pushbutton. Is there any way to program the table? Im just take callback only. Do I have to take the create function, cellselectionfunc and etc in my m-editor?
I want to make a 3 by 3 matrix, but I cannot edit the row at property inspection. When I delete the 4th row and I apply, its always has 4 rows. I just want to make 3 by 3 matrix. Not 4 by 3.
Assuming the tag property on your uitable is MyTable the following code will get the data from the table.
data = get(handles.MyTable,'Data');
If you put this code into your button callback (assuming your button has a tag of MyButton this will be function MyButton_Callback(hObject, eventdata, handles)) you should be able to see the table data when the button is clicked.
You can initialise the table data in the figures 'OpeningFcn' (which should have been created by Guide) to a 3x3 cell matrix.
handles.output = hObject;
% Initialise MyTable data to a 3x3 matrix
set(handles.MyTable,'Data', cell(3,3));
% Update handles structure
guidata(hObject, handles);

Resources