Hello Mike,
In WebDataGrid I set
protected void WebDataGrid1_Init(object sender, EventArgs e)
{
WebDataGrid grid = sender as WebDataGrid;
//列の自動作成をしない
grid.AutoGenerateColumns = false;
grid.DataKeyFields = "社員CD";
grid.EnableViewState = true;
grid.EnableDataViewState = true;
//grid.EnableAjaxViewState = true;
//grid.EnableAjax = false;
//grid.ClientEvents.Click = "WebDataGrid1_Click";
//grid.ClientEvents.AJAXResponse = "AJAXResponse";
grid.ClientEvents.KeyDown = "WebDataGrid1_Grid_KeyDown";
grid.RowUpdating += new Infragistics.Web.UI.GridControls.RowUpdatingHandler(WebDataGrid1_RowUpdating);
grid.InitializeRow += this.WebDataGrid1_InitializeRow;
grid.ItemCommand += this.WebDataGrid1_ItemCommand;
grid.ActiveCellChanged += this.WebDataGrid1_ActiveCellChanged;
// コントロール レベルで Ajax インジケーターを有効にします
grid.AjaxIndicator.Enabled = Infragistics.Web.UI.DefaultableBoolean.True;
// Ajax インジケーター表示時にマスクをかける。
grid.AjaxIndicator.BlockArea = Infragistics.Web.UI.AjaxIndicatorBlockArea.Page;
// Ajax インジケーターの位置を設定します
grid.AjaxIndicator.Location = Infragistics.Web.UI.RelativeLocation.MiddleCenter;
// コントロール固有の Ajax インジケーターの位置を設定します
grid.AjaxIndicator.RelativeToControl = Infragistics.Web.UI.DefaultableBoolean.True;
//セルのアクティブ化の有効化
if (grid.Behaviors.Activation == null)
{
Activation aActivation = new Activation();
aActivation.ActiveCellCssClass = "ActiveCellSelector";
aActivation.ActivationClientEvents.ActiveCellChanging = "ActiveCellChanging";
// 動作コレクションに追加します
grid.Behaviors.Add(aActivation);
}
//セル編集機能の有効化
if (grid.Behaviors.EditingCore == null)
{
EditingCore aEditingCore = new EditingCore();
aEditingCore.AutoCRUD = false;
aEditingCore.BatchUpdating = true;
aEditingCore.Behaviors.CreateBehavior<Infragistics.Web.UI.GridControls.CellEditing>();
aEditingCore.Behaviors.CellEditing.EditModeActions.MouseClick = Infragistics.Web.UI.GridControls.EditMouseClickAction.Single;
aEditingCore.Behaviors.CellEditing.EditModeActions.EnableOnKeyPress = true;
aEditingCore.EditingClientEvents.CellValueChanging = "CellValueChanging";
aEditingCore.EditingClientEvents.CellValueChanged = "CellValueChanged";
aEditingCore.Behaviors.CellEditing.CellEditingClientEvents.EnteringEditMode = "EnteringEditMode";
// 動作コレクションに追加します
grid.Behaviors.Add(aEditingCore);
}
//列固定化の有効化
if (grid.Behaviors.ColumnFixing == null)
{
ColumnFixing ColumnFixingbehavior = new ColumnFixing();
ColumnFixingbehavior.FixLocation = FixLocation.Left;
ColumnFixingbehavior.AutoAdjustCells = false;
ColumnFixingbehavior.ShowFixButtons = false;
// 動作コレクションに追加します
grid.Behaviors.Add(ColumnFixingbehavior);
}
//グリッドで選択動作を有効にします。
if (grid.Behaviors.Selection == null)
{
Selection aSelection = new Selection();
aSelection.CellClickAction = CellClickAction.Cell;
aSelection.CellSelectType = SelectType.Multiple;
// 動作コレクションに追加します
grid.Behaviors.Add(aSelection);
}
}
First, I set all column is BoundDataField,
for (int i = 0; i < GridData.Instance.ColumnCount; i++)
{
string key = COLUMN_DEFAULT + i;
BoundDataField gridField = new BoundDataField(true);
gridField.Key = key;
gridField.DataFieldName = key;
gridField.Header.CssClass = "hidden";
gridField.CssClass = "HorizontalAlign_Left";
aWebDataGrid.Columns.Add(gridField);
}
After, I set again Template in InitializeRow.
protected void WebDataGrid1_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
{
WebDataGrid grid = (WebDataGrid)sender;
//Set Height
if (GridData.Instance[e.Row.Index].Height > 0)
e.Row.Height = GridData.Instance[e.Row.Index].Height;
//Set template item
int start = 1;
for (int i = start; i < grid.Columns.Count; i++)
{
int rowIndex = e.Row.Index;
int columnIndex = i – 1;
if (GridData.Instance.ShowType.GetValue() == Common.Master.C_ShowType.LANDSCAPE)
{
rowIndex = i – 1;
columnIndex = e.Row.Index;
}
CellData rCell = GridData.Instance[rowIndex, columnIndex];
e.Row.Items[i].CssClass = rCell.ClassCss;
//Set Backgound
if (!string.IsNullOrEmpty(rCell.BackColor))
e.Row.Items[i].CssClass = e.Row.Items[i].CssClass + rCell.BackColor;
CellType cellType = rCell.CellType;
if (cellType == CellType.BOUNDDATAFIELD)
{
if (rCell.Locked)
e.Row.Items[i].Template = new LabelTemplate(e.Row.Items[i].Column.Key);
}
else if (cellType == CellType.COMBOBOX)
{
DropDownTemplate template = rCell.Template as DropDownTemplate;
if (rCell.Locked)
template.Locked = true;
e.Row.Items[i].Template = template;
}
else if (cellType == CellType.RADIOBUTTON)
{
RadioButtonTemplate template = rCell.Template as RadioButtonTemplate;
if (rCell.Locked)
template.Locked = true;
e.Row.Items[i].Template = template;
}
else if (cellType == CellType.LINKBUTTON)
{
LinkButtonTemplate template = rCell.Template as LinkButtonTemplate;
if (rCell.Locked)
template.Locked = true;
e.Row.Items[i].Template = template;
}
}
}
Linkbutton ItemCommand still working, but when datasource grid change then ItemCommand not working.
Please help me. Thank you!