Dynamically expanding CollectionView : Height of the CollectionView itself (not the items) changing when adding new items - height

I'm trying to build a calendar in which I need to insert different lists for each day. I figured the collection view under each label of a number in the month would be the best and it works so far. I only have a problem with adding new items to the collection view. It's not growing, I have to scroll down.
I'm looking for a solution that could give the possibility to dynamically extend the height of the collection view without touching the height of the items. As there are 40 "mini" collection views on the page, I need to be able to grow the height of all the collection views at once, without having each one of them growing above the text beneath.
Here's my code for the viewDidLoad:
houseNameLabelList = [[NSArray alloc] initWithObjects:#"House 1", #"House 2", #"House 3", #"House 4", #"House 5", nil]; // The array of the titles I want to display
NSInteger rowCount = [houseNameLabelList count];
CGFloat height = rowCount * 17; // 17 is the height of each item in the collection view
self.myCollectionView.frame = CGRectMake(self.myCollectionView.frame.origin.x, self.myCollectionView.frame.origin.y, 45, height); // 45 is the width of my collection view
Of course I have delegate and datasource set as "self".
The initial height of the collection view is 51 (3*17 which means 3 items), and I want it to grow to 85 (5 * 17 for the 5 items in my array).
How can I do that ?
Thanks for the tip

When adding a new item, the collectionView.contentView.bounds is changed.
I think you can expand the collectionView through call collectionView.bounds = collectionView.contentView.bounds

Related

Tabulator - responsive - Height of table

I really like tabulator but cant seem to get it to adjust to the height of the device. If I fix a height
e.g.
var table = new Tabulator("#example-table", {
height:"600px",
If obviously looks bigger on a mobile etc
Is there a way of making the table 90% or whatever of the window height ?
cheers
you can set the height as a percentage:
var table = new Tabulator("#example-table", { height:"100%",
The height property will take any valid CSS height value

C++ CListCtrl How get cell border in View List

I have a CListBox with a View of type List. It has only one column that the View of type List splits.
I need to draw a border around each Item .
The column contains a blank icon with size 1 and the text.
How can I draw the box ?
Thanks.
Try adding style LVS_EX_GRIDLINES.

QTableview properties

I need help with customizing a QTableView, I have defined a QTableView as this example show, which I found on the internet:
model = new QStandardItemModel(2,3,this); //2 Rows and 3 Columns
model->setHorizontalHeaderItem(0, new QStandardItem(QString("ID")));
model->setHorizontalHeaderItem(1, new QStandardItem(QString("Name")));
model->setHorizontalHeaderItem(2, new QStandardItem(QString("Description")));
ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tableView->setModel(model);
How can I define a size for each column separately i.e using percentages:
I would get first column 10% of the width second 50%, third 40%.
When I run the program and double click on a row in the QTableView, I can change the value of the cell clicked on , although I have defined a QTableView onDoubleclick method , I mean its like when you click on rename a file it highlights the text so you can modify, how can I disable that?
How to make the columns resizable, meaning can be resized by dragging their columns edge.
First: Use setColumnWidth() method after setModel(). For example:
//...
ui->tableView->setModel(model);
double ii = ui->tableView->columnWidth(0);
ui->tableView->setColumnWidth(1,0.4*ii);
ui->tableView->setColumnWidth(2,0.5*ii);
Third: To do this remove
ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
from your code.

Scrolling QListView to keep items in view while inserting at start of list

I have a QListView with a model that I am inserting data into. I'm inserting data at the start of the list which causes all the items in the view to scroll down.
What would be the best way to scroll the view automatically to keep the view fixed (i.e the view should move with the visible items as new items are inserted in the model)?
This seems to work. The problem was not actually scrolling to the specific index - it was finding the correct index in the first place.
The following code scrolls the view to keep the same items in the view when inserting at the start of the list. It also checks if the view is at the top of the list and does not scroll in this case.
QScrollBar *pVerticalScrollBar = m_pUi->listView->verticalScrollBar();
bool bScrolledToTop = pVerticalScrollBar->value() == pVerticalScrollBar->minimum();
int iRowIndex = m_pUi->listView->indexAt(QPoint(8, 8)).row();
int iRowCount = m_pInfoListModel->rowCount();
/*
insert text into m_pInfoListModel here
*/
// move scroll bar to keep current items in view (if not scrolled to the top)
if (bScrolledToTop == false)
{
iRowCount = m_pInfoListModel->rowCount() - iRowCount;
m_pUi->listView->scrollTo(m_pInfoListModel->index(iRowIndex + iRowCount, 0), QAbstractItemView::PositionAtTop);
}
This gives me a list of items that scroll by if I am at the top of the list, but when I wan't to look at items lower down the view stays fixed.
I guess you could give setAutoScroll(True) to QListView instance.
I would do the following:
Find the list view item that I want to keep visible and than get its coordinates using
QRect QAbstractItemView::visualRect(const QModelIndex &index)
Than with the item's coordinates I will call QScrollArea::ensureVisible(int, int, int, int) function to keep the item visible after adding each new item to the list.

Dynamic resize gridview edit template based on size of Item template

I have a GridView that displays data in up to 30 columns. Sometimes this has the effect that the gridview expand to a width that requre a horizontal scrollbar but not always. The length of the data in the columns also vary and I don't want to set a specific width, it's nice that the grid is small if half of the columns are empty.
The problem is when I enter edit mode, labels gets replaced by textboxes and those take up more width and the whole table resizes itself.
Is there any way I can keep the item template and it's labels without a fixed size but at the same time always make sure the edit template will have the same size.
I was thinking about something like this:
On "enter edit mode event"
EditTemplateTextBox.Width = CurrentItemTemplate.Width;
I was able to keep my GridView from resizing when switched to edit mode (except for the new "Update" and "Cancel" columns that get added) using this CSS:
table input
{
width: 95%;
}
You can use 100% if you want, but 95% gave a little bit of spacing between the cells.
Also, if you have other tables on the page that you don't want to be affected by this, give your GridView a CssClass and replace 'table' with the name of your css class like so:
<asp:GridView ... CssClass="myGridView">
.myGridView input
{
width: 95%;
}