Asp.net mvc JTable:如何更改、添加新的记录链接文本?(MVC4.0)

Asp.net mvc JTable:如何更改、添加新的记录链接文本?(MVC4.0),asp.net-mvc,jquery-jtable,Asp.net Mvc,Jquery Jtable,如何更改默认值+添加新记录链接J-Table中的文本?打开jquery.jtable.js(甚至是缩小版),按住ctrl+f键,然后搜索“添加新记录”以查找文件中的属性。然后将其更改为您想要显示的内容。打开jquery.jtable.js(甚至是缩小版),按住ctrl+f键,然后搜索“添加新记录”以查找文件中的属性。然后将其更改为您想要显示的任何内容。查看jTable的本地化功能,尽管它专门用于不同的语言,但您可以轻松利用此功能并为您的项目创建一个新的本地化.js文件。通过这种方式,您可以随时更

如何更改默认值
+添加新记录
链接J-Table中的文本?

打开jquery.jtable.js(甚至是缩小版),按住ctrl+f键,然后搜索“添加新记录”以查找文件中的属性。然后将其更改为您想要显示的内容。

打开jquery.jtable.js(甚至是缩小版),按住ctrl+f键,然后搜索“添加新记录”以查找文件中的属性。然后将其更改为您想要显示的任何内容。

查看jTable的本地化功能,尽管它专门用于不同的语言,但您可以轻松利用此功能并为您的项目创建一个新的本地化.js文件。通过这种方式,您可以随时更新到最新版本的jTable,而无需担心对核心jTable.js库文件所做的更改。您永远不应该直接更改在项目中引用的核心第三方库,因为您将始终处于必须升级以获取第三方库资产的最新新功能或修补程序的时刻,并且您将陷入困境,因为您无法准确记住更改的内容或如何传输您对最新版本的更改

所以在我的项目中,我有一个jTable,它加载一个“Job”数据类型。因此,我简单地在/Scripts/jtable/localization目录中创建了一个名为jquery.table.jobs.js的自定义目录和文件,这和任何地方一样好,但您可以将扩展消息js文件放在任何地方。这是jquery.table.jobs.js中的代码:

/*
    jTable localization file for jobs grid
*/
(function ($) {

    $.extend(true, $.hik.jtable.prototype.options.messages, {
        serverCommunicationError: 'An error occured while communicating to the server.',
        loadingMessage: 'Loading jobs...',
        noDataAvailable: 'No data available!',
        addNewRecord: 'Add New Job',
        editRecord: 'Edit Job',
        areYouSure: 'Are you sure?',
        deleteConfirmation: 'This job will be deleted. Are you sure?',
        save: 'Save Job',
        saving: 'Saving Job',
        cancel: 'Cancel',
        deleteText: 'Delete Job',
        deleting: 'Deleting Job',
        error: 'Error',
        close: 'Close',
        cannotLoadOptionsFor: 'Can not load options for field {0}',
        pagingInfo: 'Showing {0}-{1} of {2} Jobs',
        pageSizeChangeLabel: 'Row count',
        gotoPageLabel: 'Go to page',
        canNotDeletedRecords: 'Can not deleted {0} of {1} records!',
        deleteProggress: 'Deleted {0} of {1} records, processing...'
    });

})(jQuery);
希望您能像我一样使用捆绑和缩小功能,因此我刚刚将其添加到BundleConfig.cs类中:

   //====================================================================
            //Add jtable localization bundles for Customer messages for each type of data being managed by a jTable
            //====================================================================
            bundles.Add(new ScriptBundle("~/bundles/jtable-custom-messages-jobs").Include(
                       "~/Scripts/jtable/localization/custom/jquery.jtable.jobs.js"));

            bundles.Add(new ScriptBundle("~/bundles/jtable-custom-messages-customers").Include(
                      "~/Scripts/jtable/localization/custom/jquery.jtable.customers.js"));
            //====================================================================
然后在我的工作视图中,我简单地添加:

 @Scripts.Render("~/bundles/jtable-custom-messages-jobs");
当然,在我的客户视图中,有一个jTable加载“客户”类型的数据记录,我添加了:

 @Scripts.Render("~/bundles/jtable-custom-messages-customers");

其中捆绑jquery客户消息客户只是捆绑另一个jTable本地化覆盖脚本:/Scripts/jTable/localization/jquery.jTable.customers.js,其中包含“添加新客户”而不是“添加新作业”等特定消息。

查看jTable的本地化功能,虽然专门用于不同的语言,但您可以轻松地利用此功能,为您的项目创建一个新的localization.js文件。通过这种方式,您可以随时更新到最新版本的jTable,而无需担心对核心jTable.js库文件所做的更改。您永远不应该直接更改在项目中引用的核心第三方库,因为您将始终处于必须升级以获取第三方库资产的最新新功能或修补程序的时刻,并且您将陷入困境,因为您无法准确记住更改的内容或如何传输您对最新版本的更改

所以在我的项目中,我有一个jTable,它加载一个“Job”数据类型。因此,我简单地在/Scripts/jtable/localization目录中创建了一个名为jquery.table.jobs.js的自定义目录和文件,这和任何地方一样好,但您可以将扩展消息js文件放在任何地方。这是jquery.table.jobs.js中的代码:

/*
    jTable localization file for jobs grid
*/
(function ($) {

    $.extend(true, $.hik.jtable.prototype.options.messages, {
        serverCommunicationError: 'An error occured while communicating to the server.',
        loadingMessage: 'Loading jobs...',
        noDataAvailable: 'No data available!',
        addNewRecord: 'Add New Job',
        editRecord: 'Edit Job',
        areYouSure: 'Are you sure?',
        deleteConfirmation: 'This job will be deleted. Are you sure?',
        save: 'Save Job',
        saving: 'Saving Job',
        cancel: 'Cancel',
        deleteText: 'Delete Job',
        deleting: 'Deleting Job',
        error: 'Error',
        close: 'Close',
        cannotLoadOptionsFor: 'Can not load options for field {0}',
        pagingInfo: 'Showing {0}-{1} of {2} Jobs',
        pageSizeChangeLabel: 'Row count',
        gotoPageLabel: 'Go to page',
        canNotDeletedRecords: 'Can not deleted {0} of {1} records!',
        deleteProggress: 'Deleted {0} of {1} records, processing...'
    });

})(jQuery);
希望您能像我一样使用捆绑和缩小功能,因此我刚刚将其添加到BundleConfig.cs类中:

   //====================================================================
            //Add jtable localization bundles for Customer messages for each type of data being managed by a jTable
            //====================================================================
            bundles.Add(new ScriptBundle("~/bundles/jtable-custom-messages-jobs").Include(
                       "~/Scripts/jtable/localization/custom/jquery.jtable.jobs.js"));

            bundles.Add(new ScriptBundle("~/bundles/jtable-custom-messages-customers").Include(
                      "~/Scripts/jtable/localization/custom/jquery.jtable.customers.js"));
            //====================================================================
然后在我的工作视图中,我简单地添加:

 @Scripts.Render("~/bundles/jtable-custom-messages-jobs");
当然,在我的客户视图中,有一个jTable加载“客户”类型的数据记录,我添加了:

 @Scripts.Render("~/bundles/jtable-custom-messages-customers");

捆绑jquery客户消息客户只是捆绑另一个jTable本地化覆盖脚本:/Scripts/jTable/localization/jquery.jTable.customers.js,其中包含诸如“添加新客户”而不是“添加新作业”之类的特定消息。

直接来自jTable作者,这是迄今为止实现这一点的最佳方式

 $('#MyTableContainer').jtable({

    messages: {
        addNewRecord: 'Add new whatever'
    },

    actions: {
        //Action definitions comes here
    },

    fields: {
        //Field definitions comes here
    }
}); 

直接从JTable的作者那里获得,这是迄今为止实现这一目标的最佳方式

 $('#MyTableContainer').jtable({

    messages: {
        addNewRecord: 'Add new whatever'
    },

    actions: {
        //Action definitions comes here
    },

    fields: {
        //Field definitions comes here
    }
}); 

这是一个又快又脏的方法,有一个更好的方法。旧的帖子,但对新开发人员来说仍然值得一提-对JTable进行更新,甚至重新安装,都会使您的更改撤消。不聪明。根据Brian的帖子,jTable已经为这个定制提供了。这是一个快速而肮脏的方法,有一个更好的方法。旧帖子但仍然值得向新开发人员提及-对jTable的更新甚至重新安装都会使您的更改撤消。不聪明。根据Brian的帖子,已经为此定制提供了jTable。请将我的答案标记为其他人的正确答案请将我的答案标记为其他人的正确答案