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

Problem with filtering: false and switchbutton: true #13

Closed
fanturi opened this issue Mar 27, 2015 · 1 comment
Closed

Problem with filtering: false and switchbutton: true #13

fanturi opened this issue Mar 27, 2015 · 1 comment

Comments

@fanturi
Copy link

fanturi commented Mar 27, 2015

Hi,

There is a wrong behavior when you set filtering to false for your grid but add a control column with switchbutton to true.
If you click on the plus sign the line appear it's ok but you can't remove the line after that.
If you click on the magnifying glass icon you display the filtering line.
Maybe you could implement this kind of behavior:

  • When you click on the plus sign icon in the header the insert line appears and the plus sign disappears.
  • Add a cross sign icon in the control column to allow the user to cancel the insertion. It should be always there: it's not clear enough how to cancel the insertion.
  • When the user clicks on the plus sign icon (to add the line) or on the cross sign icon (to cancel) the line disappears and the plus sign icon on the header reappears. Of course if filtering is enabled when you click on the cross sign icon the filtering line is displayed.
@tabalinas
Copy link
Owner

Currently, the switch filtering/inserting button just toggles filtering=true inserting=false or filtering=false inserting=true of the grid. Thus it turns on filtering, even if it was turned off from the start.
The behavior you've described can be achieved redefining headerTemplate of control field like this:

headerTemplate: function () {
    var grid = this._grid;
    var isInserting = grid.inserting;

    var $button = $("<input>").attr("type", "button")
        .addClass([this.buttonClass, this.modeButtonClass, this.insertModeButtonClass].join(" "))
        .on("click", function () {
            isInserting = !isInserting;
            grid.option("inserting", isInserting);
        });

    return $button;
}

See the sample fiddle http://jsfiddle.net/tabalinas/ug4yuryo/

Anyway, the behavior you've described looks reasonable, and control field should consider initial filtering/inserting grid config.
Thank you!

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

No branches or pull requests

2 participants