cxgrid多选获取记录。不需要设置KeyFieldName

procedure CopyGridRecordToJsn(pvDataSet: TcxGridDBTableView; pvValueJsn:
    ISuperObject);
var
  i, j: Integer;
  lvField: TcxGridDBColumn;
  lvItem: ISuperObject;
begin
  
with pvDataSet, DataController do
  
begin                                           
    
for i := 0 to Controller.SelectedRecordCount - 1 do
    
begin
      lvItem :
= SO();
      try
        
for j := 0 to pvDataSet.ColumnCount - 1 do
        
begin
          lvField :
= pvDataSet.Columns[j];
          
if lvField.DataBinding.ValueType <> 'Object' then
          
begin
            lvItem.S[LowerCase(lvField.DataBinding.FieldName)] :
=
                  VarToStrDef(GetValue(Controller.SelectedRecords[i].RecordIndex, j), 
'');
          
end;
        
end;
        pvValueJsn.O[
'select.value'] := lvItem;
        pvValueJsn.O[
'select.values[]'] := lvItem; 
      finally
        lvItem :
= nil;
      
end;
    
end;
  
end;
end;
posted @ 2011-08-23 09:23  D10.天地弦  阅读(453)  评论(0编辑  收藏  举报