Multisort Datatable w/ fixed field and sort function - primeng

We have a PrimeNg datatable that has multiple columns (as most do), we need to be able to have a multiple sort happen when a user clicks on one of the 3 columns, but that column is only the first of two fields that it needs to sort on. The second field is a hidden field that will always be sorted ASC.
We have tried using multiSortMeta, multisort and sortfunctions, but are unable to get this working correct. Searching online, have only been able to find a single example of a sortFunction, but it is only for a single field.
Here is an example setup from the showcase, with some of the multisort stuff indicated.
<p-dataTable [value]="cars" multiSortMeta="multiSortMeta">
<p-column field="vin" header="Vin"></p-column>
<p-column field="year" header="Year"></p-column>
<p-column field="brand" header="Brand" (sortFunction)="mySort($event)"></p-column>
<p-column field="color" header="Color" (sortFunction)="mySort($event)"></p-column>
</p-dataTable>
How would you write the mySort function and/or change the dataTable definition to allow the user to click on the Color or Brand columns and have it sort by that field first, and the Year field second?
Any help would be greatly appreciated, as we are at our wits end trying to get this to work.

Related

How to use CheckBoxes filter in Google DataStudio?

In a Report in Google DataStudio, I have a CSV connector (for the moment).
I would like to use a check box to sort only lines who are under a value on a specific page.
The Facts: I have a field who are listed the time in seconds. I've make a simple filter
Include |MyFieldinSeconds|<=|86400
This way work.
But I whould like to add a checkbox for apply this field or not. For the viewer, this is the hard part. The checkboxes options are "Source of Data" and "Control Field", only booleen.
I've try to solve this by the group selection, by the Filter group option with the filter without success.
Thank You
Nicolas

date range search atk4

i want to do a search of range date using quicksearch item, but until now i realize that in the class quicksearch is a line with this code :
$this->search_field=$this->addField('line','q','')->setNoSave();
the only thing i did is to change into this:
$this->search_field=$this->addField('DatePicker','a','Desde :')->setNoSave();
I just change "line" to "DatePicker", so simple i guess,now if i add a quick search to my manager page has 2 icons, one with the icon search and the other with icon calendar, so if i search a date, i just select the date and hit the icon search, and gets me the all the results with that date, tha´ts perfect, but what happen if I add 2 quicksearchs and try to do a range date search?? the only message i get is "No Records Found".
So the question is.. How do i do range date search? I realize that exists another line in the function postinit:
$or->where($field,'like','%'.$v.'%');
maybe it will work if i put another query?
$or->where($field>=$v) or something like that?? i have spend more than 3 days trying to do this range date search?
So if anyone has some corrections with this code i would be more than happy
Try this
$or->where(array(
array($field,'>=',$from_date),
array($field,'<=',$till_date),
));

NG-Grid Filter not working correctly

I have a really basic grid using Angular.js and NG-GRID with the showFilter: set to true.
However if I search for the value in the Marketing Start Date Column, 200101011. It doesn't show. Actually as soon as I start typing a 2 in the filter text it should find all four records, but only 2 show up....
Here's the Plnkr
http://plnkr.co/edit/D3nFkQ
Thank you.
The problem appears to be the null values in your table. The search does not seem to go past a cell containing null. Hence the strange filtering behaviour. If you replace the nulls with empty strings or other values the search works perfectly.
There is an issue logged on ng-grid on GitHub - filter search box returns prematurely when cell contains an object. Since null is an object the solution suggested may work for you.

angularjs ng-grid computed column

I'm trying to emulate a spreadsheet using AngularJS and ng-grid. My needs are simple but I cannot find anything anywhere that will help me fix my code.
I have a simple table of scores and in the last column I need a "Total Score" column.
You can see my code at this plunk.
My problem is that though I was able to get the total in each row on document.load, I cannot make the "Total" column update whenever any of the scores are changed.
Or alternatively, you could add the getTotal() function directly to the model object:
http://plnkr.co/edit/LhlK1C?p=preview
I prefer solutions where I don't have to work with $watch(), but it depends if you want the total to be stored in your model or only need it for display.
You could watch for changes to the 'original_data' object and recreate the process_data object every time updates.
http://plnkr.co/edit/c4iynItnznKNRoFgeuio?p=preview

Dynamically disabling menu based on database query?

So I'm not a programmer, but my friend is. He's trying to help me develop a web/phone app but we are stuck because I'm having trouble communicating to him an idea and he is having trouble understanding. One or both of us is a moron ;) Part of the problem is that I don't even know where to search for the answer cuz I don't know the specific search terms...believe me I've tried...and I've searched stack overflow as well. Here is the problem:
Short Question:
Websites (like hotel search) allow you to search for rooms by selecting checkboxes in certain categories (i.e. smoking/nonsmoking, stars, size of bed, near downtown, etc.). Certainly these sites are referencing a large database of hotels in a city.
How can you create a site so that as you check boxes (narrow your search), other options which are no longer available are dynamically "grayed out" or disabled on the fly so you cannot check those boxes. So if I were to check 4 stars and that excluded all smoking rooms based on the database, then the option to check "smoking" would be disabled.
The key to this is that the site is querying a database as you click boxes, then based on the results of that query (which is presumably many rows of data (a subset)), it is analysing that subset of data to determine whether checkbox options should be on/off, then dynamically "graying out" specific options that are no longer available. Once you got to only a single possible result, then the site would pop up the website for that hotel (or some other action).
What is this called? Where can I get more information on this. Any pointing toward the right direction would be tremendously appreciated.
Thanks so much in advance!
Roy
HERE IS AN EDIT TO ORIGINAL QUESTION...HERE IS AN EXAMPLE:
So here is my sample database. Each Column (i.e. AA, AB, AC) represents a checkbox. '1'= True, '0'= False, and '2'= Either. Therefore, if you click checkbox AA, then only the top three rows would meet the criteria of AA=True. So query would return the top three rows. The '2's could be either True/False so since they don't affect outcome, those checkboxes should be disabled and only the checkboxes CA,CB, & CC should remain choosable. If you then click checkbox CB, then result ZYX would be output.
Conceptually, How do you go from the initial click to the point where the database is queried and the results are used to dynamically change the menu. People have suggested javascript but i am not looking for a language. I am more looking for the concept. I was thinking that the query would return a new "temp" array with just the top three rows. Then each column of this "temp" array would be queried to see if it contained a '1' in any of the rows. If it did, then that button would be turned "ON". If it didn't then that button would be turned "OFF". Is this confusing? Am I asking for too much ;)
This sounds like javascript could help. For example, using jQuery, you can dynamically send queries to databases based on whatever you click on checkboxes, and then reload a particular section of the webpage. Javascript can also dynamically disable checkboxes.

Resources