2

Razor で MVC グリッドを使用しており、次のグリッドがあります。

@(Html.Telerik().Grid<MVC.Models.List>()
            .Name("grid")
            .Columns(columns =>
            {
                columns.Bound(c => c.Id)
                    .HeaderTemplate(
                        @<text>
                            <input type="checkbox" title="check all records" id="checkAllRecords"   />
                        </text>
                    )

                    .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= Id #>'")
                    .Template(
                        @<text>
                        <input name="checkedRecords" type="checkbox"
                            value="@item.Id" title="checkedRecords" />
                    </text>)


                    .Width(50)
                    .HeaderHtmlAttributes(new { style = "text-align:center" })
                    .HtmlAttributes(new { style = "text-align:center" });
                columns.Bound(p => p.Description).Width(100);

            })
            .DataBinding(d => d.Ajax().Select("List", "Home"))
           )

JavaScript を使用してチェックされたレコードのすべての ID を取得する方法があるかどうかを知りたいですか? ご協力いただきありがとうございます。

4

1 に答える 1

1

ここにいくつかの単純な jQuery のケースのようです..

//Array for ids
var ids = new Array();

//Go through each item in the checked box list with name checkedRecords
//if the item in question is checked then insert it's value into an array
$('input[name=checkedRecords]').each(function () {
     if ($(this).is(':checked')) {
         ids[ids.length] = $(this).val();
     }
}
于 2013-04-01T20:20:08.550 に答える