简体   繁体   English

如何更新或访问JQuery Jtable中的元素

[英]How to update or access elements in a JQuery Jtable

I am new to this plugin and have been struggling with it. 我是这个插件的新手,一直在努力。 The documentation leave a lot to be desired and lacks examples, additionally, there is not much of a support community for it outside of Java. 该文档有很多不足之处,并且缺少示例,此外,在Java之外没有太多的支持社区。 I'm hoping that someone here knows the answer to my question. 我希望这里有人知道我的问题的答案。

I have a dialog that is outside of the jtable framework that adds a value to the database. 在jtable框架之外有一个向数据库添加值的对话框。 On success, I need to update a select element within the jtable "Add new record" dialog, but cannot see any way of doing this. 成功后,我需要在jtable“添加新记录”对话框中更新select元素,但看不到任何方法。 Short of telling the client to refresh their screen after they've added the value, I'm at a loss. 在告诉客户添加值后刷新屏幕的过程中,我很茫然。

Is it possible to update the select element, and if so, can someone please either point me to the correct method call within the docs or provide a small example that I can follow? 是否可以更新select元素,如果可以,有人可以将我指向文档中正确的方法调用,还是提供一个我可以遵循的小示例? I'm even open to a workaround if someone has one. 如果有人有解决方案,我什至愿意接受。


EDIT: 编辑:

This is a snippet that will attach itself to my select, adding id="client" to it. 这是一个片段,它将自身附加到我的选择中,并为其添加id="client" In the dialog that is outside of this framework, when the user adds a value to the database, I need to know how to gain access to this 'client' id element. 在此框架之外的对话框中,当用户向数据库添加值时,我需要知道如何获得对该“客户端” id元素的访问权限。 Since the event did not occur within this snippet, I don't know how to access it. 由于此代码段中未发生该事件,因此我不知道如何访问它。 I've tried appending the value using the client id but it doesn't work. 我尝试使用client ID附加值,但是它不起作用。

client: {
    title: 'Name',
    width: '20%',
    input: function (data) {
        if (data.record) {

        }
    } }

Please post your code otherwise we have nothing definitively to work off of. 请发布您的代码,否则我们将一无所有。

Here's some simple examples using jquery and ajax to update an html data table. 这是一些使用jquery和ajax更新html数据表的简单示例。

$.get(
        loadUrl,
        {sid: sid,
         dbitem: dbitem,
         newinfo: newinfo},
        function(responseText){
            $('tbody').append(responseText);//use tbody as selector & append() here
            // or you can use prepend() as your needs
        },
        "html"
    );

Here's a fiddle of another example. 这是另一个例子。

http://jsfiddle.net/W4gYY/3/ http://jsfiddle.net/W4gYY/3/

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

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