AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken Sortierung für TJvDBTreeView
Thema durchsuchen
Ansicht
Themen-Optionen

Sortierung für TJvDBTreeView

Ein Thema von Vincend · begonnen am 8. Dez 2010 · letzter Beitrag vom 9. Dez 2010
 
Vincend

Registriert seit: 8. Dez 2010
10 Beiträge
 
#3

AW: Sortierung für TJvDBTreeView

  Alt 9. Dez 2010, 22:19
*JUBEL JUBEL FREU FREU*

Endlich is es fertig!

Delphi-Quellcode:
procedure array_sortieren(i_uebergabe : Integer);
  var i_max, i_parent, i, i_ende : Integer;
      b_ende : Boolean;
      arr_test : array of Integer;
      arr_ausgabe : array of Integer;
      s_ausgabe : String;
begin
  b_ende := false;
  i := 0;
  i_ende := 1;
  SetLength(arr_test, 1);
  SetLength(arr_ausgabe, 1);

  with D_Datenmodul.qu_plz_ort do
  begin
    //Maximale Elemente das Baums finden
    Close;
    SQL.Text := 'SELECT COUNT(id_app_menue_xml_inhalte_content) as maximum ';
    SQL.Add('FROM tbl_app_menue_xml_inhalte_content ');
    SQL.Add('WHERE tbl_app_menue_xml_inhalte_id = '''+IntToStr(i_uebergabe)+'''');
    Open; First;
    i_max := FieldByName('maximum').AsInteger;
    //*****

    //Startpunkt des Baumes finden
    Close;
    SQL.Text := 'SELECT id_app_menue_xml_inhalte_content as parent_element ';
    SQL.Add('FROM tbl_app_menue_xml_inhalte_content ');
    SQL.Add('WHERE tbl_app_menue_xml_inhalte_id = '''+IntToStr(i_uebergabe)+''' + AND sub_id_app_menue_xml_inhalte_content = 0');
    Open; First;
    arr_test[0] := FieldByName('parent_element').AsInteger;
    arr_ausgabe[0] := FieldByName('parent_element').AsInteger;
    //*****

    while not b_ende do
    begin
      Close;
      SQL.Text := 'SELECT id_app_menue_xml_inhalte_content ';
      SQL.Add('FROM tbl_app_menue_xml_inhalte_content ');
      SQL.Add('WHERE sub_id_app_menue_xml_inhalte_content = '''+IntToStr(arr_test[Length(arr_test) - 1])+''' ');
      SQL.Add('AND id_app_menue_xml_inhalte_content not in (');

      for I := 0 to Length(arr_ausgabe) - 1 do //sortiertes nicht mehr beachten
      begin
        if i > 0 then SQL.Add(', ');
        SQL.Add(IntToStr(arr_ausgabe[i]));
      end;

      SQL.Add(') ORDER BY reihenfolge');
      Open; First;

      //Sortierung abspeichern & Baum-Pfadbestimmen in dem gesucht wird
      if not Eof then
      begin
        SetLength(arr_ausgabe, Length(arr_ausgabe) + 1);
        arr_ausgabe[Length(arr_ausgabe) - 1] := FieldByName('id_app_menue_xml_inhalte_content').AsInteger;
        i_ende := i_ende + 1;

        SetLength(arr_test, Length(arr_test) + 1);
        arr_test[Length(arr_test) - 1] := FieldByName('id_app_menue_xml_inhalte_content').AsInteger;
      end else
        SetLength(arr_test, Length(arr_test) - 1);
      //*****

      if i_ende = i_max then
        b_ende := true;
    end;
  end;

  for I := 0 to Length(arr_ausgabe) - 1 do
  s_ausgabe := s_ausgabe + ', ' + IntToStr(arr_ausgabe[i]);

  if (MessageDlg(s_ausgabe, mtWarning, [mbYes, mbCancel], 0) = mrYes) then
  begin

  end;
end;
Die Benennung is noch fürn hintern aber dafür wars ja auch nen Test in den Abendstunden.
Werd das die Tage mal vernünftig machen und online stellen.
Ausgehende Tabellenstruktur is ja oben.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:50 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz