English 中文(简体)
1. Creat印物体,从胎体中提取,供数据表使用
原标题:Creating a javascript object from a string for use with datatables

这个问题涉及以下网址:

var hidecols =  {"sClass": "Hide", "aTargets": [0]},{"sClass": "asdf", "aTargets": [1]},{"sClass": "qwer", "aTargets": [2]} ;

var hidecolsobj = eval( (  + hidecols +  ) );


        var oTable = $( #MainContent_OverviewTable ).dataTable({
            "sPaginationType": "full_numbers",
            "bProcessing": true,
            "bServerSide": true,
            "aoColumnDefs":
            [
                hidecolsobj, // <--------- *** HERE ***
            ],
            "sAjaxSource": "Services/Service.svc/GetDataTableOutputOverview",
            "fnServerData": function (sSource, aoData, fnCallback) {
                var jsonAOData = JSON.stringify(aoData);
                $.ajax({
                    type: "POST",
                    async: true,
                    url: sSource,
                    contentType: "application/json; charset=utf-8",
                    data:  {"Input":  + jsonAOData +  } ,
                    dataType: "json",
                    success: function (msg) {
                        fnCallback(msg);
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.responseText);
                    }
                });
            }
        });

因此,该法典没有错误,但“qwer”这一类是适用于我表格的唯一类别。 我对此进行了测试,只采用了我的物体清单中最后出现的类别。 我希望每个栏目都对隐蔽栏中的类别加以界定。 我如何能够这样做?

这是数据表网站文件中出现的方式:

$( #example ).dataTable( {
    "aoColumnDefs": [ 
        { "sClass": "my_class", "aTargets": [ 0 ] }
    ]
} );

EDIT:

            "aoColumnDefs":
            [
                { "sClass": "Hide", "aTargets": [0] },
                { "sClass": "asdf", "aTargets": [1] }, 
                { "sClass": "qwer", "aTargets": [2] }
            ],

上面的编辑工作良好,但这对我来说不是一个选择。 我需要能够生动地建立扼制的藏匿处。

最佳回答

你们正在通过数据表,以显示奥科姆尼的参数。 仅删除“扼杀”隐藏栏上的引号,使之成为一系列物体。 这将消除邪恶的必要性。

var hidecols = [{"sClass": "Hide", "aTargets": [0]},{"sClass": "asdf", "aTargets": [1]},{"sClass": "qwer", "aTargets": [2]}];

Allan

问题回答

Ah! 我是怎样做的。

Instead of doing this:

        "aoColumnDefs":
        [
            hidecolsobj, // <--------- *** HERE ***
        ],

我应该这样做:

    var hidecols =  [{"sClass": "Hide", "aTargets": [0]},{"sClass": "asdf", "aTargets": [1]},{"sClass": "qwer", "aTargets": [2]}] ;
var hidecolsobj = eval( (  + hidecols +  ) );
            "aoColumnDefs": hidecolsobj, // <--------- *** HERE ***




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签