在dbgrid顯示中有兩個計算字段,首先查詢第一個符合條件的記錄,然後顯示在DBGRID中,然後再在dbgrid顯示的結果中再進行查詢,如何利用計算字段來設置過濾條件呢?假設以計算結果>20的記錄顯示出來,1。如何利用dbgrid.datasource.dataset.filter屬性進行過濾呢?我利用它,總是提示‘找不到計算字段名’,為什麼呢?2。如何利用dbgrid.datasource.dataset.aggfields.dataset.filter屬性進行過濾呢 ?同樣提示相同的錯誤!英文提示為:‘item cannot be found in the collection corresponding to the required name or ordinal'?

解决方案 »

  1.   

    1。如何利用dbgrid.datasource.dataset.filter屬性進行過濾呢?我利用它,總是提示‘找不到計算字段名’,為什麼呢?1、将Filtered设为True。
    2、注意Filter中应写成Filter:=Filter+''''+'FieldName>20'+'''';
      

  2.   

    我也是這樣設定的,如filter:='total>20'
      

  3.   

    try
        with self.CDS_OrderMaster do begin
        Filtered:=false;
        FilterOptions:=[foCaseInsensitive];
        case self.RG_OrderStatus.ItemIndex of
        1:Filter :='FStatus=''已废弃''';
        2:Filter :='FStatus=''新定单''';
        3:Filter :='FStatus=''再联系确认''';
        4:Filter :='FStatus=''有效定单''';
        else Filter :='1=1';
        end;
        Filtered:=true;
        end;
        except
            on excep:exception do showmessage(excep.Message);
        end;
      

  4.   

    設置Filter:=Filter+''''+'FieldName>20'+'''',提示錯誤為:’arguments 
    are of the wrong type,are out of acceptalbe range,or are in conflict
    with one another'