Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slick.pager.js is not able to call the dataView functions for paging why? #1006

Open
caitu opened this issue Sep 4, 2014 · 12 comments
Open

Comments

@caitu
Copy link

caitu commented Sep 4, 2014

No description provided.

@6pac
Copy link

6pac commented Sep 4, 2014

caitu, it is ridiculous asking for help when (a) there are example pages provided that do what you want and work, so it's clearly a problem with your code, not a SlickGrid bug, and (b) you have provided no sample of your code, browser type, a jsfiddle, or anything else. GitHub is for bug reports. If you have a usage question, go to StackOverflow or progressively modify one of the sample pages.

@caitu
Copy link
Author

caitu commented Sep 4, 2014

6pac sorry for the inconvenience i tried in stack overflow but no use and you are asking for sample code here it is my sample code can you please help me
$(function () {
var jqxhr = $.getJSON('http://localhost:50305/Service1.svc/json/EmployeeDetails', function (data) {
//console.log(data);
dataView = new Slick.Data.DataView();

    dataView.setItems(data, "EmpId");

    //  console.log(dataView);
    dataView.setPagingOptions({ pageSize: 5 });

    grid = new Slick.Grid("#teamGrid", dataView.rows, columns, options);

    var pager = new Slick.Controls.Pager(dataView, grid, $("#pager"));

dataView.onPagingInfoChanged.subscribe(function (e, pagingInfo) {
var isLastPage = pagingInfo.pageNum == pagingInfo.totalPages - 1;
var enableAddRow = isLastPage || pagingInfo.pageSize == 0;
var options = grid.getOptions();

        if (options.enableAddRow != enableAddRow) {
            grid.setOptions({ enableAddRow: enableAddRow });
        }
    });

    dataView.onRowCountChanged.subscribe(function (args) {
        grid.updateRowCount();
        grid.render();
    });

grid.onSort.subscribe(function (e, args) {
console.log(args.sortCol);

        gridSorter(args.sortCol,args.sortAsc, dataView);
    });

    function gridSorter(sortCols, isAsc, dataview) {
               dataview.sort(function (row1, row2) {
            for (var i = 0, l = 1; i < l; i++) {
                var field = sortCols.field;
                var sign =  isAsc ? 1 : -1;
                var x = row1[field], y = row2[field];
                var a = parseInt(x), b = parseInt(y);
                var result = (a < b ? -1 : (a > b ? 1 : 0)) * sign;
                if (result != 0) {
                    return result;
                }
            }
            return 0;
        }, true);
    }

    dataView.onRowsChanged.subscribe(function (e, args) {
           grid.invalidateAllRows();
       // grid.invalidateRows(args.rows);
          grid.render();
    });

});
});

But in slick.pager.js some of dataview functions are not recognising i cant understand the problem(some of those are dataView.setRefreshHints, dataView.setPagingOptions({pageSize: n});)

@ldmberman
Copy link

Had you got any reasons to pass dataView.rows to Slick.Grid instead of
dataView?

On Thu, Sep 4, 2014 at 10:58 AM, caitu notifications@github.com wrote:

6pac sorry for the inconvenience i tried in stack overflow but no use and
you are asking for sample code here it is my sample code can you please
help me

var jqxhr = $.getJSON('
http://localhost:50305/Service1.svc/json/EmployeeDetails', function
(data) {
//console.log(data);
dataView = new Slick.Data.DataView();

dataView.setItems(data, "EmpId");

//  console.log(dataView);
dataView.setPagingOptions({ pageSize: 5 });

grid = new Slick.Grid("#teamGrid", dataView.rows, columns, options);

var pager = new Slick.Controls.Pager(dataView, grid, $("#pager"));

But in slick.pager.js some of dataview functions are not recognising i
cant understand the problem(some of those are dataView.setRefreshHints,
dataView.setPagingOptions({pageSize: n});)


Reply to this email directly or view it on GitHub
#1006 (comment).

@caitu
Copy link
Author

caitu commented Sep 4, 2014

If iam passing dataview, data is not binding to grid

@ldmberman
Copy link

Put your setItems call into "dataView.beginUpdate();
dataView.endUpdate();"-block

On Thu, Sep 4, 2014 at 11:07 AM, caitu notifications@github.com wrote:

If iam passing dataview, data is not binding to grid


Reply to this email directly or view it on GitHub
#1006 (comment).

@ldmberman
Copy link

https://github.com/mleibman/SlickGrid/wiki/DataView, Batching updates
section

On Thu, Sep 4, 2014 at 11:11 AM, Leo Berman ldmberman@gmail.com wrote:

Put your setItems call into "dataView.beginUpdate();
dataView.endUpdate();"-block

On Thu, Sep 4, 2014 at 11:07 AM, caitu notifications@github.com wrote:

If iam passing dataview, data is not binding to grid


Reply to this email directly or view it on GitHub
#1006 (comment)
.

@caitu
Copy link
Author

caitu commented Sep 4, 2014

Thanks for giving reply. I tried what you said but its not working i got the same error

@caitu
Copy link
Author

caitu commented Sep 4, 2014

Sorting is working nicely but problem with paging only

@6pac
Copy link

6pac commented Sep 4, 2014

the code you posted doesn't make any sense to me. for example, an unclosed function. has the site mangled your code? you need to post it in a code block. you can edit your post.

@ldmberman
Copy link

And update your code please with suggested changes.

On Thu, Sep 4, 2014 at 11:20 AM, 6pac notifications@github.com wrote:

the code you posted doesn't make any sense to me. for example, an unclosed
function. has the site mangled your code? you need to post it in a code
block. you can edit your post.


Reply to this email directly or view it on GitHub
#1006 (comment).

@6pac
Copy link

6pac commented Sep 4, 2014

or link to your StackOverflow post and continue the discussion there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants