RadListView itemTap produces “Calling js method onItemClick failed” error page

浪子不回头ぞ 提交于 2019-12-11 18:24:40

问题


I have a RadListView showing a list of items loaded from server. I want to tap on a single item and go to the detail page. I keep getting the same black error page when I tap anywhere on the listing.

Here is the component that populates it.

import { RadListView, ListViewEventData } from "nativescript-ui-listview";
...

...
public onListLoaded(args: ListViewEventData) {

    this.updateService.getReports()
    .subscribe(
        (data) => {              
            console.log("report data in reports component onListLoaded = "+JSON.stringify(data));  
            this._reports = new ObservableArray<Report>();
            this._tempreports = new ObservableArray<Report>();

            if (data["reports"]=="No Reports") {                 
                // No reports to show
            } else {  
                var status_text;
                var status_class;
                for (let i = 0; i < data.reportid.length; i++) {
                    var status_codes=this.displayReportStatus(data.report_status[i]);
                    status_text=status_codes[0];
                    status_class=status_codes[1];

                    this._tempreports.push(new Report(data.reportid[i], data.report_name[i], data.report_status[i], data.report_value[i], status_text, status_class, data.report_justification));
                }
                this._reports = this._tempreports;
                this.isLoading=false;
            }                
        },
        (error) => alert("Problems...")
   ); 
}

Here is the template:

<GridLayout orientation="vertical" tkExampleTitle tkToggleNavButton>
<RadListView class="radListView_reports" [items]="reports" (loaded)="onListLoaded($event)" (itemTap)="onReportItemTap($event)">
    <ng-template tkListItemTemplate let-item="item">
        <StackLayout class="itemTemplateStackLayout" orientation="vertical">
            <StackLayout class="reportStackLayout" orientation="vertical">                        
                <Label class="labelName blue_text bold_text list-group-item" [text]="item.report_name"></Label>

                <GridLayout class="reportDetailsGridLayout" columns="*, *">
                    <Label row="0" col="0" horizontalAlignment="left" [class]="item.status_class" class="labelStatus"  [text]="item.status_text" textWrap="true"></Label>
                    <Label row="0" col="1" horizontalAlignment="right" class="labelValue green_text bold_text" [text]="item.report_value" textWrap="true"></Label>
                </GridLayout>

            </StackLayout>
        </StackLayout>
    </ng-template>         
</RadListView>
</GridLayout>

Here is the entire error page content:

10-10 16:49:58.253 31558 31558 E MessageQueue-JNI:      at com.tns.Runtime.callJSMethodNative(Native Method)
10-10 16:49:58.253 31558 31558 E MessageQueue-JNI:      at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
10-10 16:49:58.253 31558 31558 E MessageQueue-JNI:      at com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
10-10 16:49:58.253 31558 31558 E MessageQueue-JNI:      at com.tns.Runtime.callJSMethod(Runtime.java:970)
10-10 16:49:58.253 31558 31558 E MessageQueue-JNI:      at com.tns.Runtime.callJSMethod(Runtime.java:954)
10-10 16:49:58.253 31558 31558 E MessageQueue-JNI:      at com.tns.Runtime.callJSMethod(Runtime.java:946)
10-10 16:49:58.260 31558 31558 E AndroidRuntime:        at com.tns.Runtime.callJSMethodNative(Native Method)
10-10 16:49:58.260 31558 31558 E AndroidRuntime:        at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
10-10 16:49:58.260 31558 31558 E AndroidRuntime:        at com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
10-10 16:49:58.260 31558 31558 E AndroidRuntime:        at com.tns.Runtime.callJSMethod(Runtime.java:970)
10-10 16:49:58.260 31558 31558 E AndroidRuntime:        at com.tns.Runtime.callJSMethod(Runtime.java:954)
10-10 16:49:58.260 31558 31558 E AndroidRuntime:        at com.tns.Runtime.callJSMethod(Runtime.java:946)
System.err: com.tns.NativeScriptException:
System.err: Calling js method onItemClick failed
System.err:
System.err: TypeError: listView._listViewAdapter.isGroupHeader is not a function
System.err: File: "file:///data/data/org.nativescript.myApp/files/app/tns_modules/nativescript-ui-listview/ui-listview.js, line: 539, column: 62
System.err:
System.err: StackTrace:
System.err:     Frame: function:'onItemClick', file:'file:///data/data/org.nativescript.myApp/files/app/tns_modules/nativescript-ui-listview/ui-listview.js', line: 539, column: 63
System.err:
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:970)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:954)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:946)
System.err:     at com.tns.gen.com.telerik.widget.list.RadListView_ItemClickListener.onItemClick(RadListView_ItemClickListener.java:17)
System.err:     at com.telerik.widget.list.RadListView.notifyOnTapUp(RadListView.java:723)
System.err:     at com.telerik.widget.list.ListViewGestureListener.onTapUp(ListViewGestureListener.java:175)
System.err:     at com.telerik.widget.list.ListViewGestureListener.onSingleTapUp(ListViewGestureListener.java:274)
System.err:     at android.view.GestureDetector.onTouchEvent(GestureDetector.java:656)
System.err:     at com.telerik.widget.list.ListViewGestureListener.onTouchEvent(ListViewGestureListener.java:149)
System.err:     at com.telerik.widget.list.RadListView.onTouchEvent(RadListView.java:544)
System.err:     at android.view.View.dispatchTouchEvent(View.java:12540)
System.err:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3153)
System.err:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2829)
System.err:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3159)
System.err:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2844)
System.err:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3159)
System.err:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2844)
System.err:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3159)
System.err:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2844)
System.err:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3159)
System.err:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2844)
System.err:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3159)
System.err:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2844)
System.err:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3159)
System.err:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2844)
System.err:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3159)
System.err:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2844)
System.err:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3159)
System.err:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2844)
System.err:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3159)
System.err:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2844)
System.err:     at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:601)
System.err:     at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1871)
System.err:     at android.app.Activity.dispatchTouchEvent(Activity.java:3384)
System.err:     at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:563)
System.err:     at android.view.View.dispatchPointerEvent(View.java:12788)
System.err:     at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5675)
System.err:     at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5470)
System.err:     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4963)
System.err:     at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5016)
System.err:     at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4982)
System.err:     at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5119)
System.err:     at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4990)
System.err:     at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5176)
System.err:     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4963)
System.err:     at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5016)
System.err:     at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4982)
System.err:     at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4990)
System.err:     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4963)
System.err:     at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7741)
System.err:     at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7681)
System.err:     at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7642)
System.err:     at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7852)
System.err:     at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:197)
System.err:     at android.os.MessageQueue.nativePollOnce(Native Method)
System.err:     at android.os.MessageQueue.next(MessageQueue.java:325)
System.err:     at android.os.Looper.loop(Looper.java:142)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6944)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
ActivityManager: Process org.nativescript.myApp (pid 31558) has died: fore TOP (202,1058)
ActivityManager: setHasOverlayUi called on unknown pid: 31558

If I strip down the template I get the same error eg. If I replace the ng-template with a single <Label>. And if I remove the (itemTap)="onReportItemTap($event)" from <RadListView>.

Any ideas what could be causing this? Thanks.

======== EDIT - sorry I was away for several weeks.

@Narendra Mongiya - I think it is a different issue so I thought I had better create a new question.

Tapping anywhere on this RadListView results in an error screen.

Here is some of the error text

An uncaught Exception occurred on "main" thread.
com.tns.NativeScriptException: 
Calling js method onItemClick failed

TypeError: listView._listViewAdapter.isGroupHeader is not a function
File: "file:///data/data/org.nativescript.MyApp/files/app/tns_modules/nativescript-ui-listview/ui-listview.js, line: 539, column: 62

StackTrace: 
Frame: function:'onItemClick', file:'file:///data/data/org.nativescript.MyApp/files/app/tns_modules/nativescript-ui-listview/ui-listview.js', line: 539, column: 63


at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1101)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:983)
at com.tns.Runtime.callJSMethod(Runtime.java:970) etc...

I have removed the onReportItemTap call. Here is the RadListView now:

    <RadListView [items]="reports" (loaded)="onListLoaded($event)">
        <ng-template tkListItemTemplate let-item="item">
        <StackLayout class="itemTemplateStackLayout" orientation="vertical">
                <StackLayout class="reportStackLayout" orientation="vertical">

                    <Label class="labelName blue_text bold_text list-group-item" [text]="item.report_name"></Label>

                    <GridLayout class="reportDetailsGridLayout" columns="*, *">
                        <Label row="0" col="0" horizontalAlignment="left" [class]="item.status_class" class="labelStatus"  [text]="item.status_text" textWrap="true"></Label>
                        <Label row="0" col="1" horizontalAlignment="right" class="labelValue green_text bold_text" [text]="item.report_value" textWrap="true"></Label>
                    </GridLayout>

                </StackLayout>
        </StackLayout>
    </ng-template>         
</RadListView>

And the component code:

    public onListLoaded(args: ListViewEventData) {
    console.log("In onListLoaded");
    this.updateService.getReports()
    .subscribe(
        (data) => {              
            console.log("report data in reports component onListLoaded = "+JSON.stringify(data));  
            this._reports = new ObservableArray<Report>();
            this._tempreports = new ObservableArray<Report>();

            if (data["reports"]=="No Reports") {                 
                // No reports to show
            } else {  
                var status_text;
                var status_class;
                for (let i = 0; i < data.reportid.length; i++) {
                    var status_codes=this.displayReportStatus(data.report_status[i]);
                    status_text=status_codes[0];
                    status_class=status_codes[1];

                    this._tempreports.push(new Report(data.reportid[i], data.report_name[i], data.report_status[i], data.report_value[i], status_text, status_class, data.report_justification));
                }
                this._reports = this._tempreports;

                this.isLoading=false;

                console.log("isLoading="+this.isLoading);   

            }                
        },
        (error) => alert("Problems...")
   ); 
}

public get reports(): ObservableArray<Report> {
    return this._reports;
}

There is now no itemTap listener but tapping on the screen holding the RadListView produces the error page above. Any ideas? TIA


回答1:


Looks like the handler does not like arguments for some reason. I was facing the same issue with itemTap event. So I removed the method arguments:

(itemTap)="onReportItemTap()"

I hope it helps.



来源:https://stackoverflow.com/questions/52744541/radlistview-itemtap-produces-calling-js-method-onitemclick-failed-error-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!