简体   繁体   English

根据另一个表中的选定行更新Jquery Jtable插件

[英]update Jquery Jtable plugin depending on a selected row in another Table

hello I have the following snippet of code. 你好,我有以下代码片段。 Departments 部门

  <div>Users </div>
  <div id="UserTableContainer"></div>



 <script type="text/javascript">
    var departmentChangeId = 1;


    $(document).ready(function () {


        $('#DepartmentTableContainer').jtable({
            paging: true,
            useBootstrap: true,
            sorting: true,
            selecting: true,
            selectOnRowClick: true,

            title: 'Departments',
            actions: {
                listAction: '/api/Department/GetDepartmentList',
                createAction: '/api/Department/CreateDepartment',
                updateAction: '/api/Department/EditDepartment',
                deleteAction: '/api/Department/DeleteDepartment'
            },
            fields: {
                ID: {
                    key: true,
                    list: false
                },
                TypeId: {
                    title: 'Department Type',
                    options: '/api/Department/GetDepartmentTypeList'
                },
                Label: {
                    title: 'Department'
                },
            },



            //Register to selectionChanged event to hanlde events
            selectionChanged: function () {
                //Get all selected rows
                var $selectedRows = $('#DepartmentTableContainer').jtable('selectedRows');
                departmentChangeId = $selectedRows.data('record').ID;
                //alert(departmentChangeId);
                //

                refresh();
            }
        }).jtable('load');

        $('#UserTableContainer').jtable({
            messages: ArabMessages, //Lozalize
            paging: true,
            useBootstrap: true,
            sorting: true,
            title: 'Employee',
            actions: {
                listAction: '/api/Users/GetEmployee?id=' + departmentChangeId,
                updateAction: '/api/Users/EditEmployee'
            },
            fields: {
                Id: {
                    key: true,
                    list: false
                },
                DepId: {
                    title: ' Department',
                    options: '/api/Department/GetDepartmentTypeList'
                },
                LastName: {
                    title: 'Name'
                },
            }
        });
        $('#UserTableContainer').jtable('load');
    });

and these are the two version I use for the refresh function 这是我用于刷新功能的两个版本

first 第一

function refresh() { 函数refresh(){

  $('#UserTableContainer').jtable('reload'); } 

the second 第二

function refresh() { $.post("/api/Users/GetEmployee", "id=" + departmentChangeId, function (results) { $('#UserTableContainer').jtable('reload'); } , "json"); 函数refresh(){$ .post(“ / api / Users / GetEmployee”,“ id =” + departmentChangeId,函数(结果){$('#UserTableContainer')。jtable('reload');},“ json” );

  } 

unfortunately both of them dont work instead of when I use debugging mode I see that the /api/Users/GetEmployee is visited in both case 不幸的是,它们都不起作用,而不是当我使用调试模式时,我看到在两种情况下都访问了/ api / Users / GetEmployee

请尝试在刷新功能中使用以下代码

$('#UserTableContainer').jtable('load');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM