Get column datatype, sort direction onload, change sort order on first click of header in tablesorter - client-side

I have a grid view, which has several columns, one of which is a numeric column. When the grid loads first time, the data on the numeric column gets sorted on the server side itself and gets rendered. I apply client side sorting on another column also using table sorter. Now, the requirement is, because the number column comes already sorted in ascending order, upon clicking the number column header should sort it in descending order first. How can I achieve this? I thought of doing it in the following way, but getting no help.
1. How to find out the data type of a column by giving column or index using table sorter?
2. Identify whether a column is already sorted on load and if so, the sort direction of a that column.
3. Sort that column (mentioned above) in descending order, upon first time header click of that column.
I did try with debug option of table sorter, but it is simply giving some alert message, which is not much helpful.
Any help would be really appreciated.

Set the initial sort order in tablesorter to be the same as what is returned back from the server. For example, say your numeric column is column zero and you are returning it back from the server in desc order. Use the following in the table sorter config:
sortList:[[0,1]]
This will tell tablesorter to sort the first column in descending order. Now that tablesorter knows how the data is sorted, the next time you click on this column to sort it, it will sort in ascending order (since it's currently sorted in descending order).

Related

"Calculated columns cannot contain volatile functions like Today and Me" error message on Sharepoint

I try to add a new calculated column to sharepoint list that will show elapsed day. I enter name and write a formula like;
=ABS(ROUND(Today-Created;0))
The data type returned from this formula is: Single line of text
When I want to save I get an error like
Calculated columns cannot contain volatile functions like Today and
Me.
Calculated Column Values Only Recalculate As Needed
The values in SharePoint columns--even in calculated columns--are stored in SharePoint's underlying SQL Server database.
The calculations in calculated columns are not performed upon page load; rather, they are recalculated only whenever an item is changed (in which case the formula is recalculated just for that specific item), or whenever the column formula is changed (in which case the formula is recalculated for all items).
(As a side note, this is the reason why in SharePoint 2010 you cannot create or change a calculated column on a list that has more than the list view threshold of 5000 items; it would require a mass update of values in all those items, which could impact database performance.)
Thus, in order for calculated columns to accurately store "volatile" values like "Me" and "Today", SharePoint would need to somehow constantly recalculate those column values and continuously update the column values in the database. This simply isn't possible.
Alternatives to Calculated Columns
I suggest taking a different approach entirely instead of using a calculated column for this purpose.
Conditional Formatting: You can apply conditional formatting to highlight records that meet certain criteria. This can be done using SharePoint Designer or HTML/JavaScript.
Filtered List views: Since views of lists are queried and generated in real time, you can use volatile values in list view filters. You can set up a list view web part that only shows items where Created is equal to [Today]. Since you can place multiple list view web parts on one page, you could have one section for today's items, and another web part for all the other items, giving you a visual separation.
A workflow, timer job, or scheduled task: You can use a repeating process to set the value of a normal (non-calculated) column on a daily basis. You need to be careful with this approach to ensure good performance; you wouldn't want it to query for and update every item in the list if the list has surpassed the list view threshold, for example.
I found some conversations about this issue. Many people suggest to creating a new Date Time column, visible is false, default value is Today's Date and it will be named as Today. Then we can use this column in our formulas.
I tried this suggestion and yes error is gone and formula is accepted but calculated columns' values are wrong. I setted column Today is visible and checked, it was empty. Default value Today's Date was not working. When I looking for a solution for this issue I deleted column Today carelessly. Then I realized calculated columns' values are right.
Finally; I don't know what is trick but before using Today keyword in your formulas if you create a column named as Today and after your formula saving if you delete Today column, it is working.
UPDATE
After #Thriggle's answer I realized this approach doesn't work like a charm. Yes, formula doesn't cause an error when calculated column saving but it works correctly only first time, in the next day the calculated column shows old values, because its values are static as Thriggle explained.

Filtering data and Display Heading based on filters

being a newbie to SSRS, I am trying to figure out the following:
say for instance I have a dataset which does a :
SELECT [cols...] from [some view]
I want to be able to further filter this based on parameters given from an ASP.NET site (I am using the AJAX control toolkit for the report viewer). There could be x amount of parameters and potentially can be filtered on 1 or more columns.
First question is, how would I filter the dataset and pass along the parameters along with which field the filter should apply to? I may have [col1] and I want to filter it with x values.
Second question Is, I want to be able to group the results per page based upon a column. So for each grouped result set, I want them to be displayed per page (per group per page).
Then on the headers of the page, I want it to display what the page grouping is. How would I do this?
In terms of what have I tried - nothing as I DO NOT KNOW HOW, it is why I am asking the question here to see what the experts (you) can suggest and guide me.
thank you!
To do this you can create Parameters in SSRS, they do not need to be in your query or anything. Then, go to your tablix and click either ROW or column depending on the filter type and set it show/hide visibility. For example I have a report that has personal information, so i have true/false parameter that hides/shows those columns, similar I have one that hides/shows any row with a -1 for the total paid.

QTableWidget setSortingEnabled on specific column Qt

I have a table widget that contains 2 columns. The first column contains timestamps, and the 2nd column contains the message that corresponds with the timestamp. I want the user to be able to click on the header for the timestamp column and reverse the order. I also want the user to be able to click on the message header and have all the messages be put in alphabetical order. Using setSortingEnabled works perfectly for the message header, but due to the format of the timestamp, this will not sort the timestamps correctly. Is there a way to setSortingEnabled() on just the messages column, and when the user clicks on timestamp header it calls a custom function that sorts?
SetSortingEnabled() affects all columns.
You can setSortingEnable(False), create a function with custom sorting for the timestamp-column and standard sorting for the other columns and connect the horizonterHeaders signal sectionClicked() with this function. I tried in pyqt5, it works, but much work with recognizing the actual sortOrder, setting and deleting headerIcons etc..
A much easier way is, to set an appropriate format for the timestamp, right-aligned, fixed length, on the left filled with '0', in python3 e.g.:
ts = '{:0>15}'.format(timestamp)
left filled with spaces works too:
ts = '{: >15}'.format(timestamp)

Using 'Filter by Column Value' and multi column filtering using a java vector - xPages

I have an xPage which I have built with 3 combo boxes and 1 view control. I would like to use the 'Filter by column value' option within the view control to provide the options to filter the values, allowing the user to display any combination of the combo boxes. e.g. Only comboBox1, or comboBox1 and comboBox2, or comboBox3 only, or comboBox1 and comboBox2 and comboBox3.
I used the example in the 'xPages Demonstration Application' (http://www-10.lotus.com/ldd/ddwiki.nsf/dx/xpagesdemoapp.htm or http://xpagesblog.com/XPagesHome.nsf/Entry.xsp?documentId=AAC8E26599256FDC852578CB0066CC13) to do the multi-column filtering using a vector of non-categorized columns.
So, I have come across what appears to be a fairly major issue whereby the data needs to be sorted by date. Date is not one of the filters, but it needs to be the first column in order for the data to be sorted correctly. So my first column is a string, YYYYMMDD, to ensure the data is sorted correctly. I tried to use the sort option within the view control and that does not appear to work with the column filtering implemented in this manner.
So, as Date one of the criteria I am filtering by, I have passed that as an empty string - using the thought process that an empty string will select all (as in the url examples above).
The code I have used to do the filtering is:
var vtr:java.util.Vector = new java.util.Vector();
var t1 = sessionScope.Email;
var t2 = sessionScope.Own;
var t3 = sessionScope.Module;
vtr.addElement("");
#If(sessionScope.Own=="My calls",vtr.addElement(t1),vtr.addElement(""));
#If(sessionScope.Own=="My calls",vtr.addElement(""),vtr.addElement(t2));
#If(sessionScope.Status=="Open",vtr.addElement("Open"),vtr.addElement(""));
#If(sessionScope.Module=="All",vtr.addElement(""),vtr.addElement(t3));
return vtr;
What I have found is that not all data is being returned. I thought this might be due to the date field. So I removed it (changing the view and removing the first add element), and yet I still find that not all data is being returned. I suspect that this might be due to the empty strings being passed, or, that this does not actually work the way I had hoped.
Does anyone know if I can get this working the way I want it to, and if not, do you have any suggestion on how I can go about this?
Date is not needed as the first sortable column in the view. The first column does need to be sorted for the lookup to work just like the Notes view needs to be sorted for #DbColumn and #DbLookup to work. XPages uses the same underlining architecture. This example - http://dev.openntf.org/demos/demoapp.nsf/viewFilteringVector.xsp - works without the data being sorted by Date.
My guess as to why your example isn't working is down to how your Notes view sorted. Try creating a new view with column 1 (email) ascending sort, column 2 (own) ascending sort, and column 3 (module) again ascending sort. You should be able to get vector filtering working in this situation.
If all that doesn't work for you, you might consider multi-layer category filtering (new to 853). This filtering type in XPages is related to how categoryFilter works but allow you to filter a view by the sub-category (or sub-categories) too. This technique might suit your scenario better. Hope this helps.

ASPXGridView (devexpress) Hyperlink column sorting

I have a DevExpress ASPx GridView control and am trying to implement sorting for the grid columns.
The gridView contains has integer values in one column, text in the rest. I also have a column which contains hyperlinks and is added through the code behind during run time.
I am using the Aspxgrid_CustomColumnSort event for sorting the grid.
I can achieve the sorting for the column which contains the integer values and texts successfully, however the same code is not working for the column with hyperlinks.
When I click on the column header the hyperlinks sorts in ascending order,
but when I click the header the second time the grid isnt getting sorted in the descending order, the hyperlinks are sorted in randomn order ( neither ascending nor descending)
And, further clicks on the header do not do anything.
Any advice/suggestion will be greatly appreciated.
Maybe this link will help: http://www.devexpress.com/Support/Center/p/B145444.aspx. In this page, someone had reported an issue using the GridViewDataHyperLinkColumn.

Resources