Re: Search Column in TreeView



On Sun, Nov 14, 2010 at 11:09 AM, Zettai Muri <zettaimuri gmail com> wrote:
Hi All,

I have a strange problem with my main program I am developing.  I am
attempting to specify which column may be searched via:
use constant NAME_COL => 2;
...
$treeview->set_search_column(NAME_COL);

Or even if I set the column to something irrelevant, i.e.:
$treeview->set_search_column(800); # there are only about 5 columns in
my treeview

The search as you type matches only occur on the first column.

In most of my treeviews the first column is the ID column.
So typing 1723 goes to the row that has '1723' in the first column.

But if I type 'Star Wars' for example which appears in the name column
then nothing happens (no match occurs).

I spent a good hour or so this morning trying to create a Short
Self-Contained Example (SSCE) reflecting the above issue but
"unfortunately" that one works just great.  If I specify column 3,
searches as you type occur on column 3.  If I specify column 4 then it
again works and matches what is typed.

I copied code from my main app to create the treeview in the SSCE.

I am now completely lost as what to do.

Is anyone able to list some common mistakes that I may be making, or
things to check for?

While grasping for straws this morning I tried to find differences
between my main app and the SSCE, which led me to:
* Whether or not it was a libglade (main app) gui Versus a GtkBuilder gui
- I created both kinds and the SSCE worked fine regardless of gui file format.

* Whether or not having Japanese characters in one of the columns
interefered with the search in someway
- SSCE worked fine with and without a column of Japanese characters

One thing I haven't tried and I have no idea if it could be affecting
it is that I am populating my ListStores with data from a MySQL
database in my main app while the SSCE is populated from an array
within it.
Can any of you gurus think of something here that may be making it
only match the first column?

I know I'm reaching but am out of ideas.  If anyone has anything that
I should be checking, please let me know.

Many thanks.

zettai.


Woohoo!  Figured it out.

I was passing my treeview amongst subs as a copy rather than a
reference.  Now I do:

create_treeview(\$my_new_tv);

sub create_treeview
{
    my $treeview = shift;
    # Create columns
    ....
    $$treeview->append_column($tc_id);
    $$treeview->append_column($tc_name);
    ....
    $$treeview->set_search_column(NAME_COL);
}

And the search as type works for the specified column.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]