I have a strange request and I'm not sure there is a better way other than simply brute force, but I have a CActiveDataProvider being rendered and virtual properties of the underlying Model are being used.
I would like to be able to pass extra information to that Model to filter the calculations in those virtual properties.
For example, assume there is a virtual property method getCreated_Widget_Count() that returns the number of widgets that the entity (let's say it is a widget maker) has created it its lifetime.
I would like to be able to filter the count to a specific date range.
So I want to be Create a CActiveDataProvider and use it in a CListView to display each of the elements, and the view is accessing property created_widget_count. But I want it to, sometimes, limit the result to a number based on an date range.
The obvious thing to do is iterate over the entire data set first and set the range to filter in each object, but I was hoping that there was a way to pass information to the CActiveDataProvider that could get into each constructor so that could be done while they are being built.
Any ideas?
Related
I have an OrderItems class that inherits BindingList. It stores a list of Order lines. These are presented in a DataGridView. The user can directly access the DGV and update values of each row and add new row.
When the user uses a "Save" button, I want to find all the rows that have changed, so I can then process them. How can I do that?
One idea I've had is to when instantiating the OrderItem Object, I keep another list in the OrderItems object to store original values, then iterate though the bindingList comparing against the original values in the other list? Seems a bit wasteful and intensive but there'll be only 10 or so items in the binding list.
Or should I have another field in the bindingList Object to store a flag that I'd have to set when a user changes a value in one of the rows cells (if so what event would be the best?), then iterate though the bindinglist, look for items with the flag set and just process them?
Its been a bit of a struggle understanding the DGV/Binding process, so I'd appreciate some guidance. I have looked online but most guides seem to deal with datatables/views and C#
I am using RavenDB to store data in documents which I want to query later dynamically for generating some visual charts. I have an ASP.Net interface where the user can apply filters, include exclude certain criteria. This is a normal requirement in search pages and I thought RavenDB is perfect for it. However I am not sure how to generate the filters dynamically, do I need to create index on all fields in advance?
In one thread I read about LuceneQuery but there is no simple example out there documenting how to apply and remove filter criteria dynamically via LuceneQuery.
Kindly help and suggest how I can implement it. With Entity Framework I simple used to build the expression dynamically based on some values and then pass it in where clause.
Update: Ok so to be more specific I have a page where I am generating charts using dynamic queires. User has multiple filters that he can modify like, Year From, Year To, Category, Sub Category, Sales By Specific Salesman etc.
All this data is stored in one table or document so to speak. I want to group data based on user filters which can only be determined at run time, then execute a query that fethches result using "AND" operator among the filters. So that only those records that exactly match the criteria (Not the scores that Lucene calculates during search) are grouped and summary is returned so that I can generate charts on them. Hope I made sense this time
This question is related to my previous question, Creating a Rails partial that is model-agnostic.
I am trying to create a Rails partial that is given a variable, say, seasonal_type, and does several different operations, such as querying a resource, and accessing instance variables, based on the value of the variable.
To be more concrete: I have the two models SafetyTest and TeamDue, which belong to Student. In one particular case in this partial, I need to call either
#student.safety_tests or #student.team_dues. I would like to pass the variable seasonal_type to the partial and like that determine which of the two is executed. How would I be able to do this? The value of the variable could be whatever is most convenient, such as a symbol (:safety_test) or a model (SafetyTest).
There is also another part to this question. In my controller, I precaculcated some instance variables for SafetyTest and TeamDue, such as #valid_safety_test and #valid_team_due. In my partial, how can I use either of these two instance variables, based on the value of seasonal_type? Or should I just calculate these values inside the partial, even though that would be against the MVC structure?
Any help would be much appreciated.
Here is the answer:
In my controller, I created an array with the models of both seasonal types: [SafetyTest, TeamDue]
Then I iterated over this array, and used the model to query all the information that I needed from the database. I put that information into an array and passed it on to the view with an instance variable. So this array also has two items, one for SafetyTest and one for TeamDue.
Then the partial iterates through this array and renders the view necessary.
I am provided a reference to a NSArray that contains data items. In my Custom View controller that acts as a data source for the table view, I interpret each item and present it as a cell.
So far so good.
Now there is a requirement from my colleagues to implement a filter, that will be based on values of one of the item's properties.
This property has enumerated values (4 of them). So when I apply the filter, i should see only items that match the particular value.
My question is how should I approach this filtering of that data.
1) Should I set the _data private variable to point to the original data source, and then override the "data" property getter to take into account the filtering?
2) Should I generate a separate filteredData array inside my controller?
3) Some other approach?
NOTE> coredata+fetched resultscontr. is out of the question. The number of items never will be more then 150-200.
I would go with the second choice. Having a filteredDatasource is more convenient. This way, you are able to know , not only the cells you should display, but also how many they are etc. Moreover, if in the future you want to sort them and use sections, you will be far more flexible.
For example when you implement the method – tableView:numberOfRowsInSection: which is called many times internally using the filtered data source you do not have to traverse through the array's objects many times so as to see which of them should pass the filter. You just return [filteredDatasource count]. This is more efficient.
In the apps I work on we have a array of all items and a copy which is the one the datasource refers to. When a filter is applied it replaces the copy but is based on the original array. So I guess #2.
The problem is as follows, a group of users (~50k) must be filtered from a DB, four fields for each user must be saved into a variable, then a second process will take each user and proceed to enable some licences into another system/platform. Both processes will be developed into the same application.
My first attempt was basically a query looping through the users but I wonder if thinking in objects is a better approach.
I was thinking in a structure inside an object to hold the 4 parameters, then pass each user object to the other object however considering the amount of data I'm not sure if this is fine.
Thanks,
ps. newbie using vb.net and framework 3.5
if you read the dataset directly from DB then table columns will have the type of original table in DB,,, If some the filed's its bool, int string then no need to create objects from that dataset and you can make your filters using Data view and then pass this data view to the other process...