Thursday, April 10, 2014

EditTable, Add records at the bottom

protected override void AddNewRecords() { int Added = this.AddNewRecord; base.AddNewRecords(); Added -= this.AddNewRecord; ArrayList al = new ArrayList(this.DataSource); ArrayList mv = new ArrayList(al.GetRange(0, Added)); al.RemoveRange(0, Added); al.InsertRange(al.Count, mv); al.CopyTo(this.DataSource); System.Collections.Generic.List mvu; mvu = this.UIData.GetRange(0, Added); this.UIData.RemoveRange(0, Added); this.UIData.InsertRange(this.UIData.Count, mvu); }

Tuesday, February 22, 2011

Primary key on custom query table

If you start with a TableControl from one database table, and later add some other joined table, the primary key ends being the combination of both table's primary keys, so the EditRowButton and such pass an incorrect value.
Solution: define a virtual primary key for the query being the primary key of the main table, and edit button's parameter to pass that value explicitely and not the control's PK.

Monday, February 21, 2011

More on using edit page as add

When implementing the changes noted before, you'll see that Formulas for controls only allow to enter data in "Initialize when ... Editing Record"
However, if you go to Custom Properties for the control, you can enter this key:
InternalUse:NewRecordFormula
And it will take the formula for "Initialize when ... Adding Record"
It would be nice to find in the templates or code generator properties where or how ISD enable or disable this properties in the formula tab, but in the meantime this works.

Thursday, February 17, 2011

Modify code generator templates

In your ISD installation folder, navigate to

..\Designer\CodeGenerator\Templates

There you have all the files used to generate the code behind for pages. They're XSL files wich contain plain code (th resulting) and meta code. In order to use the changes proposed in the previous post, I modified

RecordControls.cs.xsl

There I found the corresponding places and made the changes:

- In PageLoad(), around line 513, commented out: Panel.Visible = false;
- In CreateWhereClause, around line 1441, commented out exception throwing and added return null;
- In GetRecord, around line 2724 added some code, copied from line 2713, to return a new record if RecordUniqueID is null;

Now all the Edit pages create in ISD applications can be used as Add pages, without having to handcode.

Wednesday, February 16, 2011

Edit Record Page used as Add

In Section 1, TableRecordControl class, override the following methods:


public override WhereClause CreateWhereClause()
{
WhereClause wc;

try
{
wc = base.CreateWhereClause();
}
catch
{
wc = null;
}
return (wc);
}

public override void LoadData()
{
base.LoadData();
System.Web.UI.WebControls.Panel Panel = (System.Web.UI.WebControls.Panel)MiscUtils.FindControlRecursively(this, "EntityRecordControlPanel");
if (Panel != null){
Panel.Visible = true;
}
}

public override EntityRecord GetRecord()
{
if (string.IsNullOrEmpty(RecordUniqueId))
return new EntityRecord();
else
return base.GetRecord();
}

Monday, December 13, 2010

CSL (Comma Separated List)

A little SQL trick:

-- Recordset a CSL
select REPLACE(REPLACE(REPLACE((SELECT rtrim(CityID) as AFROM BaseCityORDER BY CityIDFOR xml PATH ('')),'</A><A>',','),'</A>',''),'<A>','')

 -- CSL a Recordset

declare @list varchar(1000)
set @list = 'Juan,Pedro,Alberto'
declare @x xml
set
@x = '<A>' + REPLACE(@list,',','</A><A>') + '</A>'

select x.item.value('.','varchar(20)') as nombre
from @x.nodes('//A') as x(item)

Table and Field Names

Don’t hardcode you table or field names.
Use something like; AttributeGroupMapRecord.TableUtils.TableDefinition.TableAliasName + "." + AttributeGroupMapTable. agm_AttributeGroup_ID.InternalName or just AttributeGroupMapTable. agm_AttributeGroup_ID.InternalName.

In the SP the table alias is most likely AttributeGroupMap_
filter.AddFilter(new BaseClasses.Data.SqlFilter(AttributeGroupMapRecord.TableUtils.TableDefinition.TableAliasName + "." + AttributeGroupMapTable. agm_AttributeGroup_ID.InternalName + " = " + AttributeGroupID.ToString()));

http://sjc.ironspeed.com/post/show_single_post?pid=1266475843&postcount=3