This is a migrated thread and some comments may be shown as answers.

Update grid from callback - AngularJS

3 Answers 209 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Casper
Top achievements
Rank 1
Casper asked on 06 Jan 2016, 04:56 AM

I have a grid with a list of reports. The user must accpet/reject a report by clicking the command buttons. After that, the moderator.person_aname must be updated in the grid show who accepted/rejected it. Everything works fine, except the moderator.person_aname does not change. Even the confirm/reject buttons hide correctly. Please help!

Angularjs function
$scope.confirm = function(report) {
        $wamp.call('confirm_report', [report.id]).then(
            //callback
            function (new_report) {
                $log.log(new_report);
                report.is_confirmed = new_report.is_confirmed;
                report.is_rejected = new_report.is_rejected;
                report.moderator.person_aname = new_report.moderator.person_aname;
                var grid = $("#recentReportsGrid").data("kendoGrid");
                var select = grid.dataSource.get(report.id);
                select.moderator.person_aname = new_report.moderator.person_aname;
            },
            //error callback
            function (err) {
                $log.log("user.get_status error:", err);
            }
        );
    };

 

Grid columns

{
    template: "<span ng-if='#: is_confirmed #'>Confirmed</span><span ng-if='#: is_rejected #'>Rejected</span><span ng-if='#: !(is_confirmed||is_rejected) #'>Pending</span>",
    field: "is_confirmed",
    title: "Decision",
    width: 60
},{
    field: "moderator.person_aname",
    title: "Moderator",
    width: 50
},{
    command: [{
        template: '<a class=\'k-button\' ng-show=\'dataItem.demo_info.demo_on_web_server\' target=\'_blank\' ng-href=\'{{dataItem.demo_info.url}}\'><i class="icon-edit"></i>' +
                        '<span>Download Demo</span>' +
                    '</a>' +
                    '<button ng-hide=\'dataItem.is_confirmed||dataItem.is_rejected\' class=\'k-button\' ng-click=\'confirm(dataItem)\'><i class="icon-edit"></i>Confirm</button>' +
                    '<button ng-hide=\'dataItem.is_confirmed||dataItem.is_rejected\' class=\'k-button\' ng-click=\'reject(dataItem)\'><i class="icon-edit"></i>Reject</button>' }
        ],
        title: "Actions",
        width: 210
}

3 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 08 Jan 2016, 08:24 AM

Hello Casper,

 

Please try to use the set() method of the dataItem to update its properties as documented here:

 

http://docs.telerik.com/kendo-ui/api/javascript/data/model#methods-set

 

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Casper
Top achievements
Rank 1
answered on 08 Jan 2016, 09:29 AM
It worked! Thank you Kiril!
0
Kiril Nikolov
Telerik team
answered on 08 Jan 2016, 12:02 PM

Hello Casper,

 

Happy to help.

 

In case you have any further questions, please do not hesitate to contact us.

 

Regards,
Kiril Nikolov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Casper
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Casper
Top achievements
Rank 1
Share this question
or