cell Id or textbox Id or columnID

Jan 31, 2014 at 9:43 PM
Hi, i am newbie in javascript and MVC.
i do a Grid like that:
@model  IEnumerable<DalcoEF_MVC.Models.Estado>

@using GridMvc.Html
<body>
    <h1>Lista de Obras</h1>
    <hr />
    <div style="width:500px;">
        @Html.Grid(Model).Columns(columns =>
                    {
                        columns.Add(c => c.Nombre ).Titled("Herramienta").Filterable(true);
                        columns.Add(c => c.NombreEstado).Titled("Estado");
                        columns.Add(c => c.Cantidad).Titled("Cantidad");
                        columns.Add()
                          .Encoded(false)
                          .Sanitized(false)
                          .SetWidth(30)
                          .RenderValueAs(o => @<input type="text" class="mygridtxt" />);
                        }).WithPaging(3).Sortable(true)
    </div>
    <button id="btn">Out text values</button>
    <script type="text/javascript">
        $(function () {
            $('#btn').click(function () {
                $('.mygridtxt').each(function () {
                    console.log($(this).val());
                });
            });
        });
   </script>
</body>
But, i can´t do a validation of the column CantidadEntrada (with class = mygridtxt) with the column named "Cantidad"...
All code of jquery or JavaScript that i could see ask the Id of the textbox or class, but in Grid.MVC I don´t know what name is assigned to this textbox.

Becasue my english is poor i will put an example:

idProduct Cantidad Cantidad Enviada()
1 30 5___ -->here must be an inputBox -->Its Ok ,is less
2 20 23___ -->here must be an inputBox --->not ok, greater
3 15 ____ -->here must be an inputBox ---> empty, do nothing


when the user set this values, the javaScript must comprarer with the column Cantidad (quantity or stock in english) and if ok, store the id (value in the first column) and on submit, pass all ids that was storage in the array...
Coordinator
Feb 5, 2014 at 3:09 AM
You can pass to txt attributes all the data that you need to validate the field:
.RenderValueAs(o => @<input data-cantidad="@o.Cantidad" type="text" class="mygridtxt" />);

$('.mygridtxt').each(function () {
                    console.log($(this).val(), $(this).attr('data-cantidad'));
                });