我的问题是:如何通过计算字段订购 DBGrid。我正在使用 C++Builder Starter Editon,并且在此版本中没有可用的 ClientDataSet 来在字段上创建索引并按列的索引排序。所以这不是一个选项。(在许多线程中阅读此内容)我正在使用 TIBDataSet(下面的 ibds)并且正在过滤数据。工作正常....对于 DB 列,而不是计算的列...关于我如何解决这个问题的任何想法?
void __fastcall TForm1::DBGrid3TitleClick(TColumn *Column)
{
static cIdx = 0;
static String oby = "ASC";
TBookmark CurrentPosition;
TIBDataSet *ibds = IBDS_accountsDist;
CurrentPosition = ibds->GetBookmark();
if (cIdx != Column->Index) {
oby = "ASC"; // ANOTHER column choosen
} else if (oby == "ASC") {
oby = "DESC";
} else oby = "ASC";
cIdx = Column->Index;
ibds->Filtered = false;
switch (Column->Index){
case 0: ibds->Filter = "ORDER BY SumAj "+oby; break; // SumAj is a calculated field => Does not work
case 1: ibds->Filter = "ORDER BY CSAL_ACCOUNTNAME "+ oby; break; // DB-field WORKS FINE
}
ibds->Filtered = true;
ibds->GotoBookmark(CurrentPosition);
}