如何将jQuery表的数据发送到SQL

发布于 2025-02-10 02:11:29 字数 2067 浏览 0 评论 0原文

我有一个带有属性设置为可排序的jQuery表(我可以拖放行),

<script type="text/javascript">
    $(function () {
        $("#tblLookup1 tbody").sortable({
            items: 'tr',
            cursor: 'pointer',
            axis: 'y',
            dropOnEmpty: false,
            start: function (e, ui) {
                ui.item.addClass("selected");
            },

            stop: function (e, ui) {
                $("#tblLookup1 tbody tr").each((idx, tr) => {
                    $("td:nth-child(4)", tr).text(idx+1);
                });
                ui.item.removeClass("selected");
               
            },
            receive: function (e, ui) {
                $(this).find("tbody").append(ui.item);
            }
        });
    });

现在在更新了名称偏好的列后,第一行将具有偏好值= 1,2nd low = 2,等等...

现在,这些值可以使用,直到我刷新页面为止。为了进行永久更改,我想用新的首选项值更新数据库。
这是基于.NET MVC ADO的Web应用程序
ques)如何将这些偏好值存储到某个列表中,然后将其传递/发布到SQL数据库。

查看文件代码

                    <thead>
                        <tr >
                            <th>ID</th>
                            <th>Name</th>
                            <th>Active</th>
                            <th>Order By</th>
                        </tr>
                    </thead>
                    <tbody>
                        @if (ViewBag.data != null)
                        {
                            foreach (var item in ViewBag.data)
                            {
                                <tr>
                                    <td>@item.AutoID</td>
                                    <td>@item.Text<br </td>
                                    <td >@item.Active</td>                                      
                                    <td>@item.OrderBy</td>
                                </tr>

                            }
                        }
                    </tbody>

I have a jquery table with property set to sortable( I can drag and drop rows),

<script type="text/javascript">
    $(function () {
        $("#tblLookup1 tbody").sortable({
            items: 'tr',
            cursor: 'pointer',
            axis: 'y',
            dropOnEmpty: false,
            start: function (e, ui) {
                ui.item.addClass("selected");
            },

            stop: function (e, ui) {
                $("#tblLookup1 tbody tr").each((idx, tr) => {
                    $("td:nth-child(4)", tr).text(idx+1);
                });
                ui.item.removeClass("selected");
               
            },
            receive: function (e, ui) {
                $(this).find("tbody").append(ui.item);
            }
        });
    });

Now after sorting a column with the name preference gets updated, 1st row will have preference value=1, 2nd row =2 and so on...

Now these values are available until I refresh the page. So as to make permanent changes I want to update the database with the new preference values.
This is a .net MVC ado based web app
Ques) How can I store these preference values into some list and later pass on/post to sql database.

view file code

                    <thead>
                        <tr >
                            <th>ID</th>
                            <th>Name</th>
                            <th>Active</th>
                            <th>Order By</th>
                        </tr>
                    </thead>
                    <tbody>
                        @if (ViewBag.data != null)
                        {
                            foreach (var item in ViewBag.data)
                            {
                                <tr>
                                    <td>@item.AutoID</td>
                                    <td>@item.Text<br </td>
                                    <td >@item.Active</td>                                      
                                    <td>@item.OrderBy</td>
                                </tr>

                            }
                        }
                    </tbody>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文