PDA

View Full Version : Update single row in NSScrollView




Marimuthu
Mar 28, 2012, 02:09 AM
Dear All,

I have a scroll view control which i used to display some data.
Is it possible for me to just update a single row which I select in the scroll view?

I know that I can call reloadData on the scroll view object but this will update all the elements in the row which I do not desire.

I did try this code

NSRect rectForDisplay = [ viewObj rectOfRow:rowSelected ];
[viewObj setNeedsDisplayInRect:rectForDisplay];

But I find that any changes to the data corresponding to the row (at the backend) is not reflected/updated in that row.

Could somebody help me resolve this issue?

Thanks & Regards.



Marimuthu
Mar 30, 2012, 01:03 AM
Is it not possible to update an individual cell in a scroll view?

Don't I have any other option but to call reloadData method?

Thanks & Regards.

blueillusion
Mar 30, 2012, 03:36 AM
Do you mean update a single row in a tableview (embedded in a scroll view?)
If so, it is definitely possible. I'm doing this in a few of my own apps as well.

When I get home from work, I'll try to paste the relevant code.
I ran into the same problem as you, but I can't exactly remember the correct solution at the moment.

gnasher729
Mar 30, 2012, 04:13 AM
Dear All,

I have a scroll view control which i used to display some data.
Is it possible for me to just update a single row which I select in the scroll view?

I know that I can call reloadData on the scroll view object but this will update all the elements in the row which I do not desire.

You can't call reloadData on a scroll view. You can call it on a tableview inside the scroll view.

Now read the documentation for reloadData and read a bit further on that page.

Marimuthu
Mar 30, 2012, 04:15 AM
Yes, I want to update a single row.

I am relatively new to UI development hence please forgive me if my question is obvious to many.

In my app, I call the reloadData using an object derived from NSScrollView to update all the rows. I am working on a project which this UI was implemented by somebody else who is not available now.

I am not sure if I am embedding the tableview into scrollview.

If there is an mechanism to get the pointer to tableview from Scrollview object and then using the tableview object to access and update individual cells in table view, then i think the requirement is achieved.

Sydde
Mar 30, 2012, 10:36 PM
If there is an mechanism to get the pointer to tableview from Scrollview object and then using the tableview object to access and update individual cells in table view, then i think the requirement is achieved.

Try the NSScrollView method -documentView, that should return the table view.