Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9023645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:48:39+00:00 2026-06-16T05:48:39+00:00

I have a grid and a select control on the page. Choosing any select

  • 0

I have a grid and a select control on the page. Choosing any select value triggers grid update. That updating is done using computed. Can I manually trigger grid to update, say, in situation when a new value is added to a grid?

 function vm(){
    var self = this;

    self.items = ko.observableArray([]);
    self.chosen_category = ko.observable("");

    self.pager = {
        page_namber : ko.observable(1),
        page_size : ko.observable(10)
    };

     self.sort = {
       field : ko.observable('name'),
       dist : ko.observable('asc')
     };
     // etc. 

     self.fetch = ko.computed(function(){
        $.ajax({
               url: '/api/items/',
               type: 'GET',
               data: ko.toJSON(self),
               contentType: 'application/json',
               success: self.items
          });
     }, self);


      self.add_item = function() {
        //here I want to update the grid
        self.fetch(); // not work
      };
 }

Sure I can move it to a separate function but I am looking for a cleaner solution.
Thanks!

working version :

          function vm() {
            var self = this;

            self.items = ko.observableArray([]);
            self.chosen_category = ko.observable("test");

            self.pager = {
                page: ko.observable(1),
                size: ko.observable(10)
            };

            self.sort = {
                field: ko.observable('name'),
                dist: ko.observable('asc')
            };

            self.fetch = function () {
                var data = {
                    category: self.chosen_category(),
                    pager: ko.toJS(self.pager),
                    sort: ko.toJS(self.sort)
                };

                $.ajax({
                    url: '/api/items/',
                    type: 'POST',
                    data: ko.toJSON(data),
                    contentType: 'application/json',
                    success: self.items
                });
            };

            self._auto_update = ko.computed(self.fetch).extend({ throttle: 1 }); ;

            self.add_item = function () {
                self.fetch();
            };
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:48:40+00:00Added an answer on June 16, 2026 at 5:48 am

    It is better to do this with subscription instead of computed. In that case you can define fetch function to use for both subscription and manual call:

    function vm(){
      var self = this;
    
      self.items = ko.observableArray([]);
      self.chosen_category = ko.observable("");
    
      self.fetch = function(){   
        $.get('/api/items/' + self.chosen_category(), self.items);
      };
    
      self.chosen_category.subscribe(self.fetch);
    
    
      self.add_item = function() {
       //here I want to update the grid
       self.fetch(); 
      };
    }
    

    Also you can do the same with computed:

    function vm(){
      var self = this;
    
      self.items = ko.observableArray([]);
      self.chosen_category = ko.observable("");
    
      self.fetch = function(){   
        $.get('/api/items/' + self.chosen_category(), self.items);
      };
    
      self.doStaff = ko.computed(self.fetch);
    
    
      self.add_item = function() {
       //here I want to update the grid
       self.fetch(); 
      };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dojox.grid.DataGrid where I want to select a row programmatically. I'm using
In in aspx page, there is a grid view, that has template control for
I'm using Telerik's Grid control from the MVC Extensions. I have it set up
I have created a grid function using list control. There are two columns in
i have a grid view in the web custom control and want to select
I have a collection of items in grid(of telerik) and after I select any
I have a grid view that bounded to an object data source that select
I have a feature matrix implemented with Silverlight's Grid where users need to select
I have grid in my ASP.NET page (actualy it's Telerik RadGrid). There is GridButtonColumn
I have grid of images, when the mouse is over any given image a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.