editable Textbox and Custom Validator(?) in a grid

Jan 28, 2014 at 10:46 PM
hi, i am looking for an example that have a textbox in a cell (I could already do) and when click in a submit button(outside of the grid) take every textbox with a value, and compare with a value of the other cell in the same row and (if is minor) then do an action ...

PD:sorry for my English
Coordinator
Jan 30, 2014 at 1:57 AM
Hi,

It easy to implement using jQuery.
First rendering textbox in a cell: https://gridmvc.codeplex.com/wikipage?title=Render%20button%2c%20checkbox%20etc%20in%20the%20grid%20cell&referringTitle=Documentation
        columns.Add()
            .Encoded(false)
            .Sanitized(false)
            .SetWidth(30)
            .RenderValueAs(o => @<input type="text" class="mygridtxt" />);
Then use jQuery to get all text values:
<button id="btn">Out text values</button>
<script>
$(function(){
         $('#btn').click(function(){
                  $('.mygridtxt').each(function(){
                           console.log($(this).val());
                  });
         });
});
</script>
Marked as answer by NioDeTark on 1/30/2014 at 8:10 AM
Jan 30, 2014 at 3:10 PM
hi, thanks for your answer.
Your solution is great! but i don´t have much idea of Jscript, when you wrote "console.log...", i want to put into a list to pass to controller and then, in the controller can do it something whit this elements..
Coordinator
Feb 5, 2014 at 3:04 AM
instead of 'console.log' you can create a request and bind all data to controller action. Please see how to bind data to collection in asp.net mvc - http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx/