jQuery UI Widgets Forums Grid angular grid cell validation by callback

This topic contains 1 reply, has 2 voices, and was last updated by  Todor 10 months, 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • jahangir
    Participant

    Hi,
    I need to validate jqxGrid cell depending result from server. But validation message shows as ‘invalid value’ though still server not responded. How can i wait for callback from server for validation message?

    columns: any[] =
            [
                {
                    text: 'Code',  datafield: 'code',  width: 140,  
                    validation: (cell, value): any => {
    
                        if (value.length > 0) {
    
                            this.mainGrid.showloadelement();
                            this.itemService.getItemByCode(value).subscribe(value1 => {
                                if(value) {
    								setTimeout(() => {
    									this.mainGrid.hideloadelement();
    									// some code
    									return true;
    								}, 1000);
    							} else {
    								return { result: false, message: 'Not found' };
    							}
    							
                            });
    
                        } else {
                            return true;
                        }
    
                    }
                },}
                },
                { text: 'unitLog',  datafield: 'unitLog', hidden: true,  cellbeginedit: this.cellbeginedit },
                { text: 'Note',  datafield: 'operatorComment', cellbeginedit: this.cellbeginedit},
            ];

    Todor
    Participant

    Hello jahangir,

    You just could not return value(for example true/false) directly in a subscription, because it is an async call. An async call means it is running in the background (actually scheduled for later execution) while your code continues to execute.

    You have to do all calculations with the server data in the service and then return true/false from the service.
    You could review the following example whether it fits your needs.

    Let us know if you need further assistance.

    Best Regards,
    Todor

    jQWidgets Team
    https://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.