Friends,
I have tweaked SysTableBrowser form to show only the fields/Field list based on the query we give in the Table browser. It is little difficult to see the field values in the browser specially if a table has more fields [we need to use scroller and sometimes becomes difficult to identify the field in the table browser]. Please note: This is only helpful for the developers to quickly see the fields he would like to in Table browser.
In the standard, If we write field list in the query and run it, only the fields queried upon will be retrieved and other fields/columns will not be retrieved. But this will still not help us as we need to still scroll and search for the field values in the Table Browser.
Standard Table browser as of now:
Below is the Sales Table browser: I am trying to retrieve SalesId and CommissionGroup as shown below. As we see, rest all fields values cannot be retrieved except SalesId and CommissionGroup but still I have to scroll in the grid to find out the sales ID value.
To overcome this : I have tweaked SysTableBrowser form to display only the fields which developers are looking for.
Please note: This is only helpful for the development team as they will be knowing the Fieldnames in the table.
Below is the tweaked SysTableBrowser: As you can see Only commission Group and SalesId are visible in the Table Browser
along with the system fields.
To see all the fields again, change the query back to SELECT * from SalesTable
Please note: This is quick enhancement and can be customized/optimized more as per the developer needs. Please test this before using it.
Add a new method to SysTableBrowser form as shown below.
void enableFieldList(str _statement)
{
#define.from(‘FROM ‘)
Container fieldIdsCon;
int i, j;
FieldName fieldName;
DictTable dt;
DictField dictField;
fieldId fieldId;
SysDictField sysDictField;
SqlDictionary dictionary;
str tmpStatement = strreplace(_statement, #from + dictTable.name(), ”);
;
tmpStatement = strdel(tmpStatement, 1, 7); // remove select reserve word
if (tmpStatement != ‘* ‘)
{
fieldIdsCon = str2con(tmpStatement, ‘,’);
}
if (conlen(fieldIdsCon) > 0)
{
dt = new DictTable(tablename2id(dictTable.name()));
for (fieldId = dictTable.fieldNext(0);fieldId;fieldId = dictTable.fieldNext(fieldId))
{
dictField = dictTable.fieldObject(fieldId);
if (!dictField.isSystem() && dictField.visible())
{
if (dictField.arraySize() > 1)
{
for( j = 1; j <= dictField.arraySize(); j++)
{
sysDictField = new SysDictField(dictTable.id(), dictField.id(), j);
ds_ds.object(fieldname2id(tablename2id(dictTable.name()), dictField.name() + strfmt(‘[%1]‘,j))).visible(false);
}
}
else
{
ds_ds.object(fieldname2id(tablename2id(dictTable.name()), dictField.name())).visible(false);
}
}
}
for (i = 1 ; i <= conlen(fieldIdsCon); i++)
{
fieldName = strlrtrim(strfmt(‘%1′,conpeek(fieldIdsCon, i)));
select firstonly dictionary where dictionary.TabId == TableName2id(dictTable.name()) &&
dictionary.name == fieldName;
if (dictionary || strendswith(fieldName, "]"))
{
ds_ds.object(fieldname2id(tablename2id(dictTable.name()), fieldName)).visible(true);
}
}
}
else
{
dt = new DictTable(tablename2id(dictTable.name()));
for (fieldId = dictTable.fieldNext(0);fieldId;fieldId = dictTable.fieldNext(fieldId))
{
dictField = dictTable.fieldObject(fieldId);
if (!dictField.isSystem() && dictField.visible())
{
if (dictField.arraySize() > 1)
{
for( j = 1; j <= dictField.arraySize(); j++)
{
sysDictField = new SysDictField(dictTable.id(), dictField.id(), j);
ds_ds.object(fieldname2id(tablename2id(dictTable.name()), dictField.name() + strfmt(‘[%1]‘,j))).visible(true);
}
}
else
{
ds_ds.object(fieldname2id(tablename2id(dictTable.name()), dictField.name())).visible(true);
}
}
}
}
}
Call the above method in the ExecuteSQL button >> clicked method as shown below.
Happy Dax6ng,
Sreenath Reddy
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.