customizing a table sort - classic ASP - javascript

I must sort a table according to the header clicked (only two columns) by the user. The info is coming from a DB and then Im filling an array, the two sorting routines are working pretty well and I basically need to enable both sorting methods at a time.
I guess I should code a few javascript lines in the header, a kind of,
ID
And use some variable in ASP to catch the value changed from javascript but I don't know how achieve that. Handling a session won't work because it is on server side.
Any ideas or suggestions are welcome.
Ps. I'm looking into TableSorter JQuery Plugin but it looks lot more than I need and that implies to learn JQuery, I'd like to use a simplest method.

You could change your link to something like this -
ID
Then in your code behind check for the QueryString parameter and sort your table accordingly. Something like -
If Request.QueryString("sort") = "id" Then
'perform sort by id
ElseIf 'other sort logic
End If

Related

Oracle Apex sorting interactive grid

it is possible to use static LOV (default, newest, latest) to sort interactive grid by date column? I tried to use order by in query, but it's not allowed.
Thank you in advance
As far as I can tell (which means that someone might know better), you can't do that because interactive grid's select statement doesn't support order by clause; if you try to add it, you'd get
ORDER BY clause is not supported, use column sorting instead.
which means that - once you run the report - navigate to "Actions" menu, go to "Data" and choose the "Sort" option.
Can that help in what you're trying to do? Perhaps! How? By saving the custom report. So:
sort data any way you want
go to "Actions > Report > Save as", give it a name and save it
repeat these steps as many times as you want
when you're done, you'll see new option in the toolbar which will let users pick report they want, without having to manually sort data themselves. Something like this (a simple interactive grid based on Scott's emp table):

Set an HTML table with filters and sorting

I am looking for a script that allows me to insert in an html table the possibility of filtering data with the same (or almost) elasticity that for example Excel offers, that is the possibility of filtering certain elements even on multiple fields, the possibility of order in ascending and descending order and also the possibility of filtering all elements, for example greater or less than a certain number.
Is there something a thing like that?
Thanks a lot for the support!
Datatables is the solution:
Url: https://datatables.net/
You have multiple plugins/extensions for this... You can do everything you imagine...
Select by column value:
https://datatables.net/examples/api/multi_filter_select.html
Search in each column:
https://datatables.net/examples/api/multi_filter.html
By the description of your issue I would suggest you to take a look at the Datatables website or in the Tabulator website. Both work pretty well and are very easy to get up and running.

How to get the next result for the right paginating

I need to know how to use exactlly the paginating function.
I have read that offest isn't the only way, and there an many ways to paginating between the results.
I would like to paginating without reload the site it's possible?
I got this example
SELECT * FROM Table LIMIT 100, 5000
I expect to put it in a function or in <a> or in button + Eventlistener...
I don't get it how to displaying the next number of result and next on.
Hope what i try to explain is clear.
Thx for the help.
If you are using classic asp indeed, then you can make use of the recordset pagination features.
You might want to have a look at this tutorial: ADO Recordset paging in ASP

Hierarchy table - activation of rows through javascript?

I've created a database-driven hierarchy table with 3 hierarchy levels. It works almost exactly how I want it to, but the javascript code that drives its functionality is UGLY. I would like to re-write some of it, but I don't quite know how. I imagine I'll have to use recursive functions, but there are some strange business rules that may make it more difficult than I imagined. Can you make any suggestions to simplify my current code (in particular, the ActivateRow() function)? See fiddle.
Note that there is some funky use of hidden fields due to ASP.NET Web Forms postbacks and losing input values, but there are some useful data-attributes written into the HTML such as data-region-id, data-subregion-id, data-market-id, and data-hierarchy-id. the main requirements are below:
There are two tables - the first is linked to the second, so all actions on the first table should be carried out on the second table as well (though the second table is slightly different).
Three levels of hierarchy. The highest level (Region), a middle level (Sub Region), and a final level (Market)
Row activation enables all controls in a given row. If the activated row is a Sub Region row, it deactivates its parent Region row controls and its sales values sum up to the Region level. This does not apply to activating a Market row.
Similarly, row deactivation should disable and clear all controls within that row. If the row is a parent row, it should clear all children rows and disable their controls as well.
Deactivating all children of a parent row should deactivate the parent row and clear all parent row controls.
Surely, there's a better alternative. Am I reinventing the wheel? Is there anything out there that I could use to improve my spaghetti code? I realize this isn't the best question for Q&A format - is there somewhere else I should ask my question?
It is not entirely clear what you are doing but from what I gather you have some kind of table you are filtering.
Also, you are using ASP.NET webforms.... so sorry for you.
I would not use any kind of form binding controls offered by ASP WebForms, because it is now obsolete, incorrect and very painful.
Instead, create an AJAX enabled page [WebMethod] that returns all the data or filtered with a parameter, what ever, in JSON (Because JSON is easier to read and debug, and much faster than XML)
Go and find the jQuery plugin DataTables. Everykind of functionality is built in and extentable, it works great, super efficient client side, with varios filtering and searching capabilities.
You either create a new model on the Server side and remap the data server side, or dump your existing model and remap it on the client, either way, you just plug JSON data into datatables.
Saving back to webforms is slightly more tricky (compared to MVC/Razor) because you have to take the String and deserialise it to your model, its a few extra lines but I do this all the time and you can carry on with your business logic.

Classic ASP Auto Suggest Like Google

While working on a project i came across a functionality in which i need to implement auto suggest textbox using classic asp. I did it and it works fine. I'm using XMLHttp Request object to pick the database column values when user enter something in textbox.
Everything works fine. But if the table have too many rows (37,000+) in it, the performance of the application decreases. Please suggest what steps should i take in order to improve the performance in this case.
why not just showing a SELECT TOP 15 [name] ...?
why do you need to show them all...
if someone enters "B" I really (as a user) don't expect you (the application) to show me all the possibilities.
...or am I wrong?
P.S. you need to start using something like jQuery ... in around 10 lines you would do the same as all your javascript code ;-)
added
It is normal to have the auto suggest box only start suggesting after the first 3 characters been typed ... try this first!
just add in your showHint method
if (str.length < 3) return;
Use indexes on the database fields that you have in your where-statement in the query and it will go much faster.

Categories