This project is read-only.

cell Id or textbox Id or columnID

Jan 31, 2014 at 10: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
    <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");
                          .RenderValueAs(o => @<input type="text" class="mygridtxt" />);
    <button id="btn">Out text values</button>
    <script type="text/javascript">
        $(function () {
            $('#btn').click(function () {
                $('.mygridtxt').each(function () {
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...
Feb 5, 2014 at 4: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'));