none
Is there a way to get all rows from a JSGrid? RRS feed

  • Question

  • I know about the "GetSelectedRecordKeys", that has been used in many of the examples, but I am looking for a function that returns all records in the JSGrid. Not just visible ones or selected ones, but all of them. I need to do some calculations that require looking at all records on the current grid and presenting the results in a separate custom grid below it.

    Thanks in advance!

    Carlos


    Friday, August 20, 2010 9:42 PM

Answers

  • And thanks to Sivaramen here is the answer:

    Yes, we can get the rows bound to JsGrid using the table cache object.

     

    Type.registerNamespace("GridManager");

    GridManager = function () {

       

        var _dataSource;

     

        this.Init = function (jsGridControl, initialData, props) {

            if (initialData) {

                _dataSource = new SP.JsGrid.StaticDataSource(initialData);

                var jsGridParams = dataSource.InitJsGridParams();

                jsGridControl.Init(jsGridParams);           

            }

        }

     

        function GetAllRecords() {

            if (_dataSource && _dataSource.tableCache) {

                var ranges = [{ pos: 0, count: _dataSource.tableCache.GetRecordCount()}];

                var allRecords = _dataSource.tableCache.GetRecords(ranges).records[0];

                return allRecords;

            }

     

            return null;

        }

    };

     

    1.       Have a global variable _dataSource

    2.       I assume that you are assigning data through Init method.

    3.       Assign the _dataSource in Init method

    4.       Call GetAllRecords() to get all the records

    Best regards,

    Brian.


    Blog | Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
    Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page
    • Marked as answer by Jim Corbin Friday, August 27, 2010 11:39 PM
    Friday, August 27, 2010 4:19 PM
    Owner

All replies

  •  

    Can someone from Microsoft please respond to this. There is no documentation on this and I need an answer. Thanks!

    Carlos

    Wednesday, August 25, 2010 3:00 AM
  • Hi Carlos,

    I don't know the answer, but I will try and find someone who does.

    Best regards,

    Brian.


    Blog | Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
    Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page
    Thursday, August 26, 2010 10:36 PM
    Owner
  • Brian,

    I would appreciate it. My client is waiting and without proper documentation, this is my only hope.

    Please get back to us soon.

     

    Carlos

     

    Friday, August 27, 2010 3:48 PM
  • And thanks to Sivaramen here is the answer:

    Yes, we can get the rows bound to JsGrid using the table cache object.

     

    Type.registerNamespace("GridManager");

    GridManager = function () {

       

        var _dataSource;

     

        this.Init = function (jsGridControl, initialData, props) {

            if (initialData) {

                _dataSource = new SP.JsGrid.StaticDataSource(initialData);

                var jsGridParams = dataSource.InitJsGridParams();

                jsGridControl.Init(jsGridParams);           

            }

        }

     

        function GetAllRecords() {

            if (_dataSource && _dataSource.tableCache) {

                var ranges = [{ pos: 0, count: _dataSource.tableCache.GetRecordCount()}];

                var allRecords = _dataSource.tableCache.GetRecords(ranges).records[0];

                return allRecords;

            }

     

            return null;

        }

    };

     

    1.       Have a global variable _dataSource

    2.       I assume that you are assigning data through Init method.

    3.       Assign the _dataSource in Init method

    4.       Call GetAllRecords() to get all the records

    Best regards,

    Brian.


    Blog | Facebook | Twitter | Posting is provided "AS IS" with no warranties, and confers no rights.
    Project Server TechCenter | Project Developer Center | Project Server Help | Project Product Page
    • Marked as answer by Jim Corbin Friday, August 27, 2010 11:39 PM
    Friday, August 27, 2010 4:19 PM
    Owner
  • Brian,

    Are there any exmples about how to implement this?  I have followed other SDK walthroughs to add a feature to the Timesheet but this looks way different. 

    I am trying to create a feature to loop over the existing rows in the grid and make sure that the time entered is not beyond the end date of the task and that there are enough hours on the task.  If either is true I am stopping the user from submitting the Timesheet. 

    Any help is greatly appreciated,

    Jay Smith


    Jay Smith
    Thursday, October 20, 2011 5:43 PM