This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Filtertabelle nach Feld stammt....
#1
Hallo zusammen,
Ich habe ausführlich gesucht und kann die Antwort nicht finden, ich beabsichtige, die Tabelle mit einem Feld von der HTML-Seite zu filtern.
Unterhalb meines Codes möchte ich nach dem Feld "Owner.Own_Id" filtern, das ich im Code habe (Suche: "1").

function loadDataTable() {
dataTable = $('#tblData').DataTable({
"ajax": {
"url": "/Admin/Property/GetOwners",
type: "GET",
contentType: "application/json ",
dataType: "json",
success: function(date) {
alert(data.d.date)
}
},
pageLength: 10,
searchCols: [null, { search: "1" , "regex": true }, null , null, null, null, null, null],
lengthMenu: [2, 5, 10, 20, 50, 100, 200, 500],
"Spalten": [
{ "data": "prop_Id", "width": "3%" },
{ "data": "owner.own_Id", "width": "3%" },
Zitieren
#2
Ich nehme an, Sie meinen ein Feld aus Ihrer Datentabelle.
Sie sagen nicht, aus welcher Tabellenzeile Ihr Suchfeld stammen soll. Ich nehme an, es stammt aus der ausgewählten Zeile (falls vorhanden), falls Sie die Erweiterung "select" verwenden.
yourTable
    .on ( 'select', function (e, dt, type, indexes ) {
         var selected = dt.row( {selected: true} );
         if (selected.any()) {
             dt.search( selected.data().owner.own_id ).draw();
         }
    })
Als Lösung markieren Zitieren
#3
Herzlichen Dank für Ihre Unterstützung,
Am Ende habe ich eine andere Lösung verwendet, in Zukunft werde ich direkt in JSON filtern.
Unten ist die verwendete Lösung:
const ownerID = document.getElementById('Owner_Own_Id').value
 
function loadDataTable() {
    dataTable = $('#tblData').DataTable({
        "ajax": {
            "url": "/Admin/Property/GetOwners",
            type: "GET",
            contentType: "application/json",
            dataType: "json",
            sucess: function (data) {
                alert(data.d.data)
            }
        },
        pageLength: 10,
        searchCols: [null, { search: ownerID , "regex": true }, null, null, null, null, null, null],
Als Lösung markieren Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste