Hi,
I have a grid with column that contains a checkbox. When the grid loads I would like to know how many checkboxes are checked. I would also like to wire an event to each checkbox that would increment/decrement the total counter when checked/unchecked. I've attached a sample. Could you please suggest how I could modify this sample to achieve what I'm looking for?
Thanks,
Rick
Thanks Vasya, this works.
Hello Rick,
Please let me know if you need any further assistance with this matter.
I am glad that you consider my suggestion helpful.
What I can suggest regarding your requirement to hide the summaries button is to set the showSummariesButton option to false. This option controls whether or not the header summary icon to be shown. It could be set as following:
//Initialize $(".selector").igGrid({ features: [ { name: "Summaries", showSummariesButton: false } ] }); //Get var showSummariesButton = $(".selector").igGridSummaries("option", "showSummariesButton"); //Set $(".selector").igGridSummaries("option", "showSummariesButton", false);
//Initialize
$(
".selector"
).igGrid({
features: [
{
name:
"Summaries"
,
showSummariesButton:
false
}
]
});
//Get
var
showSummariesButton = $(
).igGridSummaries(
"option"
"showSummariesButton"
);
//Set
Hi Vasya,
I'll work with this, thanks. Can you tell me the best way to hide this button since it will not be in use? See attached.
What I can suggest for achieving your requirement is handling the summariesCalculated event. This event is going to be fired when the grid loads initially as well as every time a checkbox value is changed. In this event you could retrieve the count of the checked and unchecked rows and set this as a span`s text. Afterwards, you could just hide the summary rows in order to save your space. For example:
summariesCalculated: function (evt, ui) { var trueValues = ui.owner.summaryCollection().MakeFlag[0].result; var falseValues = ui.owner.summaryCollection().MakeFlag[1].result; var total = trueValues + falseValues; $("#resultSpan").text("There are " + trueValues + " checked rows from " + total); $("tr[data-role='summaryrow']").each(function (index) { $(this).hide(); }); }
summariesCalculated: function (evt, ui) {
var trueValues = ui.owner.summaryCollection().MakeFlag[0].result;
var falseValues = ui.owner.summaryCollection().MakeFlag[1].result;
var total = trueValues + falseValues;
$("#resultSpan").text("There are " + trueValues + " checked rows from " + total);
$("tr[data-role='summaryrow']").each(function (index) {
$(this).hide();
I modified my sample and I am attaching it for your reference.
I hope this will help you achieve your requirement.