Ticket T731158
Visible to All Users

GridView - How to get row values without sending callbacks to the server

created 6 years ago

Hello,

This code return only keys for current page.
How I can get all keys in all pages?

[JavaScript]
 function CollectGridData() {
            var columnCount = grid.GetColumnCount();
            var rowCount = grid.GetVisibleRowsOnPage();
            var gridData = [];
            for (var i = 0; i < rowCount; i++) {
                var row = new Object();
                for (var j = 0; j < columnCount; j++) {
                    var columnFieldName = grid.GetColumn(j).fieldName;
                     row[columnFieldName] = grid.batchEditApi.GetCellValue(i, j, false);
                }
                row["KeyField"] = grid.GetRowKey(i);
                gridData.push(row);
            }
            return gridData;
        }

Thanks

Comments (2)
DevExpress Support Team 6 years ago

    Hello,
    It is possible to access only visible row keys on the client side. Would you please clarify why you need to collect all data in Java Script? Describe the whole scenario in detail. This should help me find an efficient solution.

      Hi,

      When user click save, I want to do some check in client side before saving data.
      This is onclick save:

      JavaScript
      function OnClick(s, e) { var arraydata = CollectGridData(); var result = abp.services.app.salaryCalculateService.getMaxMonthCalculate(arraydata); result.done(function (result) { if (result == false) { abp.message.error('Process can not be complete, Because......'); return; } else { do save here } }

      Answers approved by DevExpress Support

      created 6 years ago (modified 6 years ago)

      Hello,

      Thank you for the clarification. GridView provides only visible key values. To get values from different pages, the grid sends a callback to the server. As a workaround, you can use the approach from the GridView - How to get row values on the client side without callbacks ticket. The idea is to collect required data, save it to the JSProperties collection and then access it on the client side without sending requests to the server.

      Let me know if you need further assistance.

      Thanks,
      Stanley

        Comments (2)

          Thanks, this helped.

          DevExpress Support Team 6 years ago

            Happy to help!

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.