Smart-Table icon indicating copy to clipboard operation
Smart-Table copied to clipboard

stSearch and stSelectRow not working well together

Open jvisser72 opened this issue 8 years ago • 12 comments

Hi Lorenzo,

Just found that when combining stSearch and stSelecteRow an error is generated:

Error: [$compile:ctreq] Controller 'stTable', required by directive 'stSelectRow', can't be found!

Code looks like:


<table st-table="dataCollection" st-safe-src="dataSource" class="table table-striped table-bordered">
    <thead>
        <tr>
        <th colspan="3">
            <input st-search="" class="form-control" placeholder="Filter..." type="text"/>
            </th>
        </tr>
    <tr>
        <th st-ratio="20" st-sort="Column1">Column 1</th>
        <th st-ratio="50" st-sort="Column2">Column 2</th>
            <th st-ratio="30" st-sort="Column3">Column 3</th>
        </tr>
    </thead>
    <tbody>
        <tr st-select-row="row" st-select-mode="single" ng-repeat="row in dataCollection" ng-click="setSelection(row)">
        <td>{{ row.Column1 }}</td>
        <td>{{ row.Column2 }}</td>
        <td>{{ row.Column3 }}</td>
        </tr>
    </tbody>
</table>

I use this table in a dialog, the first time the dialog pops up nothing happens and everything works fine, also filtering and selecting. When I close the popup, and open it up again, the search filter is cleared and the error above shows.

Do you have any idea why this happens, or is this a know issue?

This happens in version 2.1.0

Thanks in advance.

Jeroen

jvisser72 avatar Jul 14 '15 14:07 jvisser72

I have no idea, this looks more like a bug in angular as the controller st-table is indeed present. What version of angular are you using ?

lorenzofox3 avatar Jul 14 '15 14:07 lorenzofox3

I'm using AngularJS v1.3.15

jvisser72 avatar Jul 14 '15 14:07 jvisser72

what if you change your version ?

lorenzofox3 avatar Jul 14 '15 14:07 lorenzofox3

I'll give that a go, one moment.

jvisser72 avatar Jul 14 '15 14:07 jvisser72

Unfortunately using AngularJS v1.4.2 does not solve the problem, same error. I'll try and post a plunker tomorrow morning, so we can get to the bottom of this ;-)

Thank you for your help so far.

jvisser72 avatar Jul 14 '15 14:07 jvisser72

Hi Lorenzo,

Sorry for the late reply, but here is the plunk (procedure explained in plunk):

http://plnkr.co/edit/9rfHoFPDUQTgCbN1XTKT

If you have additional questions please let me know.

Thank you in advance for taking the time.

Regards,

Jeroen

jvisser72 avatar Jul 15 '15 10:07 jvisser72

Hi, I dont' see the procedure. Readme is empty. for me everything looks ok, does not it ?

lorenzofox3 avatar Jul 15 '15 11:07 lorenzofox3

Hi,

Just updated the README.md, but in short: http://plnkr.co/edit/9rfHoFPDUQTgCbN1XTKT?p=preview

1 Click button to choose person (modal show) 2 Enter value in the filter 3 Click close or choose button 4 Click button to choose person (modal show) 5 Look at error message:

Error: [$compile:ctreq] Controller 'stTable', required by directive 'stSelectRow', can't be found!

Looks like when the filter value is reset, the error shows, if you don't apply the filter then everything works just fine.

jvisser72 avatar Jul 15 '15 12:07 jvisser72

I am sorry but I think you are pointing me to the wrong plunker. I don't have modals, and readme is still empty screen shot 2015-07-15 at 14 20 17

lorenzofox3 avatar Jul 15 '15 12:07 lorenzofox3

Hmm... weird, can you take a look again?

http://plnkr.co/edit/9rfHoFPDUQTgCbN1XTKT

jvisser72 avatar Jul 15 '15 12:07 jvisser72

Hi, ok I was able to reproduce, I don't know exactly the cause, it might be related to a node not disposed correctly, it might be related to angular strap, I don't know at the moment. I suggest you write your own selection logic (here is an example). I'll investigate

lorenzofox3 avatar Jul 15 '15 13:07 lorenzofox3

Hi Lorenzo,

Thank you for this workaround, works like a charm.

Cheers, Jeroen.

jvisser72 avatar Jul 15 '15 13:07 jvisser72