JQuery Datatables disable/remove row count options depending on number of records - datatables

By default, datatables has 4 sizes of records to show: 10,25,50,100.
All the option are available by default no matter how many records in table.
If table has 18 entries is there any option to disable or remove 50 and 100 from the dropdown.
or if disable row count if records are less than 10.
I can't find either of these in the documentation.

You modify the length menu by the aLengthMenu setting
$('#example').dataTable({
aLengthMenu : [5, 10, 25, 50]
});
To dynamically change the menu, you must access the generated <select> box in code. It has a name, which always is table id + _length, so a table with the id example will have a length menu with the name example_length
Here an example, dynamically changing the length menu to hold 5 and 10 only
var dataTable = $('#example').dataTable();
var newLength = [5, 10];
var aLengthMenu = $('select[name=example_length]');
$(aLengthMenu).find('option').remove();
for (var i=0;i<newLength.length;i++) {
$(aLengthMenu).append('<option value="'+newLength[i]+'">'+newLength[i]+'</option>');
}
To disable the menu, simply add the disabled attribute
$(aLengthMenu).prop('disabled', 'disabled');
working demo with the code above http://jsfiddle.net/Mz5WZ/

Related

How to add widget to entire column in a QTableWidget?

New to PyQt5. I'm trying to create a Table using QTableWidget where certain columns are spin box or drop down widgets. I am able to add create a widget and it to a particular cell. I have the following questions:
How do I automatically add these widgets when a user add a new row to a table? From reading the documentation, it seems I can use itemDelegateForRow, but I'm not sure which methods to implement from the QAbstractItemDelegate class. Can someone point me to a small example on how to use this?
The column Parent is a combo box whose values need to get updated with a list of all other values in column Block. By default, it has a single item 'top'. When a row is added with say, Block=A, then in the 2nd row the list of valid choices for Parent shoudl be A, top, etc. What signal should I monitor/connect to update the combox box and how?
Right now, I have the following code to create a 5x5 table.
hier_blocks = QTableWidget(5, 5)
hier_blocks.verticalHeader().setDefaultSectionSize(25)
hdrs = ['Block', 'Parent', 'Library', 'Freq (MHz)', 'Qty']
hier_blocks.setHorizontalHeaderLabels(hdrs)
parent_box = QComboBox(hier_blocks)
parent_box.addItem('top')
hier_blocks.setCellWidget(0, 1, parent_box)
lib_box = QComboBox(hier_blocks)
hier_blocks.setCellWidget(0, 2, lib_box)
freq_box = QSpinBox(hier_blocks)
freq_box.setRange(1, 4000)
hier_blocks.setCellWidget(0, 3, freq_box)
qty_box = QSpinBox(hier_blocks)
qty_box.setRange(1, 20)
hier_blocks.setCellWidget(0, 4, qty_box)
hier_layout = QVBoxLayout()
hier_layout.addWidget(hier_blocks)

Try to check if column consists out of 3 numbers, and change the value to the first number of the column

I'm trying to create a new column called 'team'. In the image below you see different type of codes. The first number of the code is the team someone's in, IF the number consists out of 3 characters. E.G: 315 = team 3, 240 = team 2, and 3300 = NULL.
In the image below you can see my data flow so far and the expression I have tried, but doesn't work.
You forget parenthesis () in your regex :
Try :
^([0-9]{3})$
Demo

Python selenium get table values into List of Lists

I'm just trying to get the data from this table:
https://www.listcorp.com/asx/sectors/materials
and put all the values (the TEXT) into a list of lists.
I've tried so many different methods using--> xpath, getByClassName, By.tag
------------
rws = driver.find_elements_by_xpath("//table/tbody/tr/td")
---------------
table = driver.find_element_by_class_name("v-datatable v-table theme--light")
--------------
findElements(By.tagName("table"))
--------------
# to identify the table rows
l = driver.find_elements_by_xpath ("//*[#class= 'v-datatable.v-
table.theme--light']/tbody/tr")
# to get the row count len method
print (len(l))
# THIS RETURNS '1' which cant be right because theres hundreds of rows
And nothing seems to work to get the values in an easy way to understand the manner.
(EDIT SOLVED)
before doing the SOLVED solution below.
First do: time.sleep(10) this will allow the page to load so that the table can actually be retrieved. then just append all the cells to a new list. YOU WILL NEED MULTIPLE LISTS to fit all the rows.
So basically you can use find_elements_by_tag_name
and use this code
row = driver.find_elements_by_tag_name("tr")
data = driver.find_elements_by_tag_name("td")
print('Rows --> {}'.format(len(row)))
print('Data --> {}'.format(len(data)))
for value in row:
print(value.text)
Have proper wait to populate the data.

Count items in Infopath field

I created a form in Infopath with a rich text box field. The field is used to keep a list of usernames (first and last). I want to be able to keep a of count each entry and keep a tally. I then want to use that total # of entries to add or subtract from other fields. Is there any way to do that?
Is the rich text box field just a large string? If so you could just use python's built in split function, and either split by ("\r\n"), or (",").
Example:
u = "Bob, Michael, Jean"
x = u.split(",")
X will be a list of usernames. If you are using line breaks for each new username, then replace (",") with ("\r\n").
Now to count the items in a list you just need to iterate on the list you created with a for loop.
Example:
b = 0
u = "Bob, Michael, Jean"
x = u.split(",")
for i in x:
b += 1 // b will be the number of usernames

Podio calculations - how to get the source of the entry chosen in a relationship field?

Lets'say I have a relationship field H where the user can choose to add a single entry from any of three different apps (X app, Y app, Z app).
I would like to use this information in a calculation field to calculate results depending on what app the info comes from, rather that the values of the incoming entry.
Is that possible?
If there is always only one related item allowed you can use .length. In this case it counts the number of the related items
var $AppX = #TitleFieldAppX.length;
var $AppX = #TitleFieldAppY.length;
var $AppZ = #TitleFieldAppZ.length;
AppX == 1 ? "Calculate this" : AppY == 1 ? "Calculate that" ? AppZ == 1 : "Calculate else" : null
If an item from App x is related than do this calculation, if from App Y .....