Y
yustory
Unregistered / Unconfirmed
GUEST, unregistred user!
2个表通过2个clientdataset做成前端主从表,在网上找了排序的函数,对结果集排序。主表正常,从表不行。百度了一下没有找到解决办法,各位高人可有遇到类似问题? <br>下面是我用到的排序函数: <br>procedure TForm1.OrderGrid(dataSet:TClientDataset;orderField:string); <br>var <br> i:integer; <br>begin <br> if dataSet.IndexFieldNames <>'' then <br> begin <br> i:=TClientDataSet(DataSet).IndexDefs.IndexOf('i'+orderField); <br> if i=-1 then <br> begin <br> with Dataset.IndexDefs.AddIndexDef do <br> begin <br> Name:='i'+orderField; <br> Fields:=orderField; <br> DescFields:=orderField; <br> end; <br> end; <br> dataSet.IndexFieldNames:=''; <br> dataSet.IndexName:='i'+orderField; <br> end <br> else <br> begin <br> dataSet.IndexName:=''; <br> dataSet.IndexFieldNames:=orderfield; <br> end; <br>end; <br>在DBGrid的ontitleclick里调用此函数,主表的DBGrid可正常排序,从表的DBGrid出错。 <br><br>期待高人指点!