Problem:I need to create a list of "divs" which will contain information regarding hostels (profile picture, a button to book a room there and some short info). This list will be dynamically created through a query to a database. The list should be paginated and only show the first n hostels by making Ajax calls to the db.
My solution: Have a template div created iteratively. Use javascript to implement the pagination requirement.
My question: Does my invent the wheel solution make sense? Or am I better off using some existing library/framework to achieve this if yes any suggestion regarding existing tool would be appreciated (It might be off topic but have failed to find a single library to achieve this).
normal table with one column and three rows
table with one column but splitted rows
There are plenty of libraries available to achieve it, one of which I used is
datatables.js
and is working fine. Has option for paging, sorting searching etc.
Just to give an idea based on your design, you can have a single column table which can have the template of your div (datatables give option to define template for your column) and then you can define sorting as well based on some of your fields data.
Paging it does automatically but you can still configure it.
It also has feature of searching, so you can give option to search for particular hostel or price or anything.
Related
I have a material-table component where I am rendering a nested materiel-table in the detail panel of each row. I would like to know if there is a way to include detail panel material-table rows in the functions offered by the package. I am mainly interested in the selection feature for now, but will likely need the same support for other functions like filtering, search, etc...
Now I know that Tree Data allows this since all rows are part of the same table. But I need to be able to do it with using the Detail Panel.
NB: For more clarity, here is a code sandbox I found with the nested table functionality.
So how would one go about adding their custom select function to a material-table, such as to include selected rows inside nested material-tables ?
The way to control the row checked state outside of the table, meaning without using the provided check box inputs, is demonstrated in a demo created after I asked the same question in the material-table-core repo. It's pretty straight forward and should help anyone trying to do the same : https://material-table-core.com/demos/selection/outside-of-table/
I am developing a webform which needs to have LineItems ie. some textboxes, calendar,dropdowns etc in a row which can be added dynamically on button click.
An example from my previous works:
I developed this using a GridView and maintained the state of controls using DataTable and ViewState on Click to Add link button.
The problem with this approach is that it becomes very slow as number of controls increase.
What are other alternatives? I know I can use repeater but I am not sure how much difference is that gonna make? I would not want to explore new way if the performance improvement is like 5%.
I can use jquery and html client side elements but then maintaing state would be a headace (I cant avoid postbacks , there are already many drop downs and fileuploads on the same form that cause postback ).
OR if there is an easy way to maintian the state of HTML elements?
This is not opinion based question since , performance and be percieved and measured.
I can think of several options:
Implement paging/limiting so customers can only see N rows at a time
Implement master-slave views: split one large table in two. Master table only lists items and slave table only show details for the currently selected row
Search for other jquery plugins, perhaps there are newer/faster plugins available (sorry couldn't offer any better alternatives, but they might exist)
You may find good answers at UX design web-site, such as How To Display Too Much Data, tables with lots of columns, Best way to display more table columns and rows than I have room for?
I'm building an mvc web app using C#. The place I am currently stuck is trying to add a cascading drop-down list. I have seen several articles on this, however my usage varies enough that I'm not sure how to implement it.
My information to populate the dropdown lists is coming from a series of sql tables. The first dropdown should show the information from one table (which lists available tables). When the user selects an option, a second dropdown list should be created and filled with the information from the chosen table.
How would I implement this cascading dropdown list which could read from any number of different tables?
I believe this will involve AJAX/javascript which I'm not very familiar with.
To better explain my data structure, this is an application for an administrator to keep track of useful information. There could be several tables such as Employees, CompaniesWorkedWith, ProjectsBeingDeveloped, BudgetItems, etc... Then a final lookup table that would contain these table names. The first dropdown would be populated with information from this lookup table. Then when the user selects an item (such as Employee) the second dropdown would grab the information from the appropriate table and display it in a dropdown. Then the user could select and item (such as an individual employee) which will then grab the details of that item and present it to the user. That last part should be easy. I'm just confused on how to get the dropdowns to cascade through multiple tables. It should be dynamic that someone can easily go in and add another table to the lookup table and have it function properly.
You need to implement callback's to update the data sources for the cascaded controls. Just use your update panels appropriately to prevent full page post-backs. If you're using a framework such as DevExpress, Telerik or ASP.NET then there's lots of options and sample source code for this exact thing.
http://www.codeproject.com/Articles/730953/Cascading-Dropdown-List-With-MVC-LINQ-to-SQL-and-A
EDIT: I realized you're second data-source depends on a second more dynamic data source. To do this I would create my own data-source implmenting IEnumerable. I have a sample of something that may help somewhere... I'll look for it.
EDIT 2:
Okay, I took a look at code similar to this (not quite the same) but here's how you can do it:
You'll need a generic container for your values for your second/third/etc. dropdown lists. This might be a List<string> or a List<MyGenericClass> with whatever properties you are filling out to represent your columns for each row in the dropdown.
Use SqlConnection, SqlCommand to iterate through the results and populate the List (or your own class that implements IEnumerable).
Assign the IEnumerable object to your dropdown list datasource.
Maybe this information is out there and my Google-fu is failing me, however I can't seem to find the answer. How can I get the number of rows being currently displayed in a jqGrid?
Every question and answer I've found on this topic tells you how to get either the total number of rows (displayed or not) or the number of rows loaded by an external service. Instead, I'm trying to get how many rows are being displayed in the current page of the jqGrid. One of my jqGrid attributes is rowList:[10,20,30], but I'm not sure how to access which one is selected myself.
All I want is how many rows are being currently dislpayed on each page of the jqGrid. The closest thing I've found so far has been this Q&A, but this displayed how many <tr>s there are and wasn't really what I needed.
$('.ui-pg-selbox').val()
Tested on the latest jqGrid (4.4.1)
Of course, if you have more than jqGrid per page, you can use an wrapper to ensure that it is the one you're looking for.
$('#myjqGridWrapper .ui-pg-selbox').val()
Not sure whether it's the best way, but it gets the job done.
The space means a descendant selector, that is it looks for elements containing the class ui-pg-selbox which are descendant of an wrapper #myjqGridWrapper. That would require having a div or some other wrapper around your table.
UPDATE: Also, if you have the table ID or a reference, you can use a more sturdy way of querying its jqGrid instance's .ui-pg-selbox:
$('#jqgridTableId').closest('.ui-jqgrid').find('.ui-pg-selbox').val()
The following will return you the number of displayed rows on a grid's page:
$('#myjqGridWrapper').getGridParam('reccount');
You shouldn't rely on the view for information. You should pull this information out of the JQGrid model. You can do so by calling the getGridParam method like so:
var rowNum = jqGrid.getGridParam('rowNum');
See here for more information: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options
I have a database no more than say 100k which I'd like to use as reference documentation for my software. It's just a simple table really - around 5 columns by a couple of hundred rows. I am looking for a decent Javascript database library; one which would feature:
Sorting by column
A tiny size. Has to be small as it is sent to the user (since I don't want anything server-side). Say no more than 50-100k.
"Update-as-you-type" functionality, and by that I mean, you can type in a filter box, and the rows filter out instantly on the HTML page, or near instantly as you're typing (client-side processing only). If no input in the filter is given, all the results would display on a single large HTML page.
Searches that allow for partial matches of any cell in the table, and preferably allow NOT, OR and obviously AND.
Furthermore, it should be free/cheap, easy to use and install, perhaps working on a CSV data file for its data.
Is there anything out there that fits the bill?
Check jQGrid OR DataTables it has most of that what you are looking for.