Skip to content

Infragistics Community Forum / Web / Ignite UI for jQuery / Obtain data from checked rows in iggrid with checkboxes

Obtain data from checked rows in iggrid with checkboxes

New Discussion
Guillaume Longtin
Guillaume Longtin asked on Jul 2, 2014 3:51 PM

Hello,

I currently have a grid that stores the data of the selected row in an array when it is clicked. This method works perfectly fine, however I'm trying to change it so I can select multiple rows with a checkbox and be able to store all that date in my array. Basically, instead of adding one row at a time in my array, I want to be able to add multiple rows checked in it. I don't know if you guys follow me but please look into my code so we can find a way to do that.

Here it is :

//
$('#GridBindContact').on('iggridselectionactiverowchanged', function (event, args) {
  $("#PrimaryKey").val(args.row.element[0].cells[1].textContent);
  $("#ContactToBind_Numcon").val(args.row.element[0].cells[1].textContent);
  $("#ContactToBind_FullName").val(args.row.element[0].cells[2].textContent + ' ' + args.row.element[0].cells[3].textContent);
  $("#ContactToBind_Titcon").val(args.row.element[0].cells[4].textContent);
  $("#ContactToBind_Tel1con").val(args.row.element[0].cells[5].textContent);
  $("#ContactToBind_Tel2con").val(args.row.element[0].cells[5].textContent);
  $("#ContactToBind_Emailcon").val(args.row.element[0].cells[7].textContent);
  $("#ContactToBind_NumEmployees").val(args.row.element[0].cells[8].textContent);
  $("#ContactToBind_NameEmployees").val(args.row.element[0].cells[9].textContent);
  $("#ContactToBind_Added").val(true);
  $(".ui-button-text").trigger("click");
});
// ]]>

@(Html.Infragistics.Grid(Of Contact)(Model.Results).ID("GridBindContact").
AutoGenerateColumns(False).
Width("100%").
Height("400px").
ResponseDataKey("Results").
Columns(Sub(column)
  column.For(Function(e) e.Numcon).Template("${Numcon}").HeaderText("Num")
  column.For(Function(e) e.Pnmcon).Template("${Pnmcon}").HeaderText("Pnm").Width("10%")
  column.For(Function(e) e.Namemcon).Template("${Namecon}").HeaderText("Name").Width("15%")
  column.For(Function(e) e.Titcon).Template("${Titcon}").HeaderText("Title").Width("20%")
  column.For(Function(e) e.Tel1con).Template("${Tel1con}").HeaderText("Tel1")
  column.For(Function(e) e.Tel2con).Template("${Tel2con}").HeaderText("Tel2")
  column.For(Function(e) e.Emailcon).Template("${Emailcon}").HeaderText("Email")
  column.For(Function(e) e.NumEmployees).HeaderText("Num Emp")
  column.For(Function(e) e.NameEmployees).HeaderText("Name Emp")
End Sub).
Features(Sub(features)
  features.Sorting().Type(OpType.Local)
  features.RowSelectors.EnableCheckBoxes(True).RowSelectorsColumnWidth("50px").EnableRowNumbering(False)
  features.Selection().Mode(SelectionMode.Row).MultipleSelection(True).AddClientEvent("activeRowChanging", "activeRowChanging")
  features.Updating().EditMode(GridEditMode.None).EnableAddRow(False).EnableDeleteRow(False)
End Sub).Render())

<form action="#" id="ajaxForm" method="post">
@Html.HiddenFor(Function(x) x.PrimaryKey)
@Html.HiddenFor(Function(x) x.ContactToBind.Numcon)
@Html.HiddenFor(Function(x) x.ContactToBind.FullName)
@Html.HiddenFor(Function(x) x.ContactToBind.Titcon)
@Html.HiddenFor(Function(x) x.ContactToBind.Tel1con)
@Html.HiddenFor(Function(x) x.ContactToBind.Tel2con)
@Html.HiddenFor(Function(x) x.ContactToBind.Emailcon)
@Html.HiddenFor(Function(x) x.ContactToBind.NumEmployees)
@Html.HiddenFor(Function(x) x.ContactToBind.NameEmployees)
</form>

I already added the feature to have checkboxes in my grid, but got nothing to handle them yet !

Thanks alot for your help, 

Guillaume 

Sign In to post a reply

Replies

  • 0
    [Infragistics] Troy Rodda
    [Infragistics] Troy Rodda answered on Jun 27, 2014 9:07 PM

    Hi Guillaume,

    So the igGrid does have the checkbox feature with the selector that enables the user to select off each row they want to add to the selected rows array : http://help.infragistics.com/jQuery/2014.1/ui.iggridrowselectors

    This would add each selected row to the array one at a time.

    But this is not really what you are looking for?

    From what you are describing, it sounds that you want to add a checkbox(es) that upon some event that is executed selects all the rows that are checked and adds them to the selected rows array in one shot as a 'batch'.

    If you can confirm or correct my understanding, and elaborate a little more as to what you need as it differentiates from the sample in the link above.

    Thanks!

    • 0
      Guillaume Longtin
      Guillaume Longtin answered on Jun 30, 2014 2:29 PM

      Hi Troy,

      Let me try to elaborate a little more for what I want to be able to do exactly. As you were saying, I want to be able to add the data from all rows that are checked in a row array as a batch. That said, let's say I checked three rows. When I press the 'OK' button, it should store the information from all three rows in my array.

      If all succeed, my array should have three 'elements'. For example, array[0] would contain the data from the first row that is checked. This would allow me to access each cells and store the 'textContent' from them in 'ContactToBind' which is what I'm using to store each cell information at the moment.

      I hope that clears it up a little bit !

      Sorry for my late answer,

      Guillaume Longtin

      • 0
        [Infragistics] Troy Rodda
        [Infragistics] Troy Rodda answered on Jul 1, 2014 2:07 PM

        Hi Guillaume,

        This will be a new product idea for the grid as there is not presently a way to load more-than-one one row at a time to the selected rows array.

        To suggest a new product idea you can do so by navigating to http://ideas.infragistics.com  The steps are easy to do: 

        1.       Create a new UserVoice account and log in to the Infragistics Product Ideas site at http://ideas.infragistics.com.

        2.       Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)

        3.       Review the feature suggestions already posted by the community.

        4.       Vote for the features you’d like to see added to the product.

        5.       If the feature you’re looking for has not been posted, you can add your own product idea. Make sure to be specific and provide as much detail as possible. Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing! 

        With this system, you are in the driver’s seat by submitting your product ideas. You can even track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you. 

        Please let me know if you need any additional assistance regarding this matter.

      • 0
        Guillaume Longtin
        Guillaume Longtin answered on Jul 2, 2014 2:15 PM

        Hi Troy,

        I'm pretty sure there's a way I can do what I'm trying to do. It's just that I'm not sure how to handle it.

        Take a look at this line of code :  var rowArray = $("#GridContactToBind").igGridSelection("selectedRows");

        Now, rowArray should have the data from all rows checked. At this point I could try to run a for loop to push the textContent in my ContactToBind values.

        Like this :

        $("#PrimaryKey").val(rowArray[index].element[0].cells[1].textContent);
        $("#ContactToBind_Numcon").val(rowArray[index].element[0].cells[1].textContent);
        $("#ContactToBind_FullName").val(rowArray[index].element[0].cells[2].textContent + ' ' + rowArray[index].element[0].cells[3].textContent);
        …

        But at this point, I don't know what to do exactly, how to push my form after each elements in rowArray.

        I don't know if that gives you a little more information to help me out.

        Sincerely,

        Guillaume Longtin 

         

      • 0
        [Infragistics] Troy Rodda
        [Infragistics] Troy Rodda answered on Jul 2, 2014 3:06 PM

        Hi Guillaume,

        I conferred with our product development and they indicated that this is a new product idea.

      • 0
        Guillaume Longtin
        Guillaume Longtin answered on Jul 2, 2014 3:51 PM

        Okay, thank you for your time.

        Guillaume 

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Guillaume Longtin
Favorites
0
Replies
6
Created On
Jul 02, 2014
Last Post
12 years, 3 months ago

Suggested Discussions

Tags

Created by

Created on

Jul 2, 2014 3:51 PM

Last activity on

Jul 2, 2014 3:51 PM