{
if( ! IsPostBack )
{
UltraWebGrid1.DataSource = System.Data.Testing.DataMaker.OneBand;
UltraWebGrid1.DataBind();
UltraWebGrid1.Bands[0].Columns.Add( "hidden" );
UltraGridColumn col = UltraWebGrid1.Bands[0].Columns.FromKey( "hidden" );
col.DataType = "System.Int32";
col.Hidden = true;
UltraWebGrid1.DisplayLayout.Bands[0].SortedColumns.Add( col );
UltraWebGrid1.DisplayLayout.AllowSortingDefault = AllowSorting.OnClient;
UltraWebGrid1.DisplayLayout.SelectTypeRowDefault = SelectType.Extended;
UltraWebGrid1.DisplayLayout.SelectedRowStyleDefault.BackColor = Color.LightSkyBlue;
}
//
// This must always execute...
//
UltraWebGrid1.DisplayLayout.Bands[0].Columns.FromKey( "hidden" ).SortIndicator = SortIndicator.None;
}
JavaScript
// called when the "Move Selected Rows Up" button is clicked
function MoveRowsUp()
{
MoveRows( "UltraWebGrid1", true );
}
// called when the "Move Selected Rows Down" button is clicked
function MoveRowsDown()
{
MoveRows( "UltraWebGrid1", false );
}
function MoveRows( gridName, moveUp )
{
var grid = igtbl_getGridById( gridName );
var selectedRowOffset;
var nonSelectedRowOffset;
if( moveUp == true )
{
selectedRowOffset = 0;
nonSelectedRowOffset = grid.Rows.length;
}
else
{
selectedRowOffset = grid.Rows.length;
nonSelectedRowOffset = 0;
}
for( var i = 0; i < grid.Rows.length; ++i )
{
var row = grid.Rows.getRow( i );
var sortValue;
var rowIsSelected = row.getSelected();
if( rowIsSelected == true )
{
sortValue = selectedRowOffset + row.getIndex();
}
else
{
sortValue = nonSelectedRowOffset + row.getIndex();
}
var hiddenCell = row.getCellFromKey( "hidden" );
hiddenCell.setValue( sortValue );
}
var hiddenColumn = grid.Bands[0].getColumnFromKey( "hidden" );
// We need to change the sort indicator so that the server-side code
// recognizes that the rows were sorted.
hiddenColumn.SortIndicator = 1; // 1 means "ascending"
grid.sort();
}