Spread for ASP.NET 9.0 Product Documentation
IsEditable Method (GroupDataModel)
Example 


Row index of the cell
Column index of the cell
Determines whether the cell in the group is editable.
Syntax
'Declaration
 
Public Overrides Function IsEditable( _
   ByVal row As Integer, _
   ByVal col As Integer _
) As Boolean
'Usage
 
Dim instance As GroupDataModel
Dim row As Integer
Dim col As Integer
Dim value As Boolean
 
value = instance.IsEditable(row, col)
public override bool IsEditable( 
   int row,
   int col
)

Parameters

row
Row index of the cell
col
Column index of the cell

Return Value

Boolean: true if editable; false otherwise
Example
This example returns the value from the specified index.
private int GetYear(DateTime value)
{
return value.Year;
}

private int GetDecade(DateTime value)
{
int x = 0;
x = value.Year % 10;
x = value.Year - x;
return x;
}

<Serializable()>
public class MyGroupComparer1 : IComparer
{
private bool birthDate = true;

public MyGroupComparer1(bool bd)
{
birthDate = bd;
}

public int Compare(object x1, object y1)
{
int x;
int y;
x = 0;
y = 0;
if (birthDate)
{
if ((x1) is DateTime)
{
x = ((DateTime)(x1)).Year % 10;
x = ((DateTime)(x1)).Year - x;
}
if ((y1) is DateTime)
{
y = ((DateTime)(y1)).Year % 10;
y = ((DateTime)(y1)).Year - y;
}
}
else
{
if ((x1) is DateTime)
{
x = ((DateTime)(x1)).Year;
}
if ((y1) is DateTime)
{
y = ((DateTime)(y1)).Year;
}
}
if (x == y)
{
return 0;
}
else if (x > y)
{
return 1;
}
else
{
return -1;
}
}
}

void FpSpread1_Grouping(object sender, GroupingEventArgs e)
{
int c = e.SortInfo.Index;
FarPoint.Web.Spread.FpSpread ss = (FarPoint.Web.Spread.FpSpread)sender;
FarPoint.Web.Spread.Model.DefaultSheetDataModel dm;
if ((ss.ActiveSheetView.DataModel) is FarPoint.Web.Spread.Model.DefaultSheetDataModel)
{
    dm = (FarPoint.Web.Spread.Model.DefaultSheetDataModel)ss.ActiveSheetView.DataModel;
}
else
{
dm = (FarPoint.Web.Spread.Model.DefaultSheetDataModel)((FarPoint.Web.Spread.Model.GroupDataModel)ss.ActiveSheetView.DataModel).TargetModel;
}

c = dm.GetDataColumnFromModelColumn(c);
if (dm.GetDataView().Table.Columns[c].DataType.Equals(typeof(DateTime)))
{
if ((dm.GetDataView().Table.Columns[c].Caption.IndexOf("Birth") >= 0))
{
e.GroupComparer = new MyGroupComparer1(true);
}
else
{
e.GroupComparer = new MyGroupComparer1(false);
}
}
}

void FpSpread1_Grouped(object sender, EventArgs e)
{
FarPoint.Web.Spread.FpSpread ss = (FarPoint.Web.Spread.FpSpread)sender;
FarPoint.Web.Spread.Model.GroupDataModel gm;
if ((ss.ActiveSheetView.DataModel) is FarPoint.Web.Spread.Model.GroupDataModel)
{
gm = (FarPoint.Web.Spread.Model.GroupDataModel)ss.ActiveSheetView.DataModel;
if ((gm.GroupComparer) is MyGroupComparer1)
{
int i;
for (i = 0; i <= ss.ActiveSheetView.RowCount - 1; i++)
{
if (gm.IsGroup(i))
{
FarPoint.Web.Spread.Model.Group g;
g = gm.GetGroup(i);
if ((g.Rows[0]) is int & !(gm.IsEditable(i, g.Column))) 
{
string s = ss.ActiveSheetView.GetColumnLabel(0, ss.ActiveSheetView.GetViewColumnFromModelColumn(g.Column));
if (s.IndexOf("Birth") >= 0)
{
g.Text = s + ": " + GetDecade((DateTime)gm.TargetModel.GetValue((int)g.Rows[0], g.Column)) + "s";
}
else
{
g.Text = s + ": " + GetYear((DateTime)gm.TargetModel.GetValue((int)g.Rows[0], g.Column));
}
}
}
}
}
}
}
Private Function GetYear(ByVal value As DateTime) As Integer
Return value.Year
End Function

Private Function GetDecade(ByVal value As DateTime) As Integer
Dim x As Integer = 0
x = value.Year Mod 10
x = value.Year - x
Return x
End Function

<Serializable()> _
Public Class MyGroupComparer
Implements IComparer

Private birthDate As Boolean = True
Public Sub New(ByVal bd As Boolean)
birthDate = bd
End Sub

Public Function Compare(ByVal x1 As Object, ByVal y1 As Object) As Integer Implements System.Collections.IComparer.Compare

Dim x, y As Integer
x = 0
y = 0

If birthDate Then
If TypeOf (x1) Is DateTime Then
x = CType(x1, DateTime).Year Mod 10
x = CType(x1, DateTime).Year - x
End If
If TypeOf (y1) Is DateTime Then
y = CType(y1, DateTime).Year Mod 10
y = CType(y1, DateTime).Year - y
End If
Else
If TypeOf (x1) Is DateTime Then
x = CType(x1, DateTime).Year
End If
If TypeOf (y1) Is DateTime Then
y = CType(y1, DateTime).Year
End If
End If

If x = y Then
Return 0
ElseIf x > y Then
Return 1
Else
Return -1
End If
End Function

End Class

Protected Sub FpSpread1_Grouped(ByVal sender As Object, ByVal e As System.EventArgs) Handles FpSpread1.Grouped
Dim ss As FarPoint.Web.Spread.FpSpread = sender
Dim gm As FarPoint.Web.Spread.Model.GroupDataModel
If TypeOf (ss.ActiveSheetView.DataModel) Is FarPoint.Web.Spread.Model.GroupDataModel Then
gm = ss.ActiveSheetView.DataModel
If TypeOf (gm.GroupComparer) Is MyGroupComparer Then
Dim i As Integer
For i = 0 To ss.ActiveSheetView.RowCount - 1
If gm.IsGroup(i) Then
Dim g As FarPoint.Web.Spread.Model.Group
g = gm.GetGroup(i)
If TypeOf (g.Rows(0)) Is Integer And Not gm.IsEditable(i, g.Column) Is Integer Then
Dim s As String = ss.ActiveSheetView.GetColumnLabel(0, ss.ActiveSheetView.GetViewColumnFromModelColumn(g.Column))
If s.IndexOf("Birth") >= 0 Then
g.Text = s & ": " & GetDecade(gm.TargetModel.GetValue(g.Rows(0), g.Column)) & "s"
Else
g.Text = s & ": " & GetYear(gm.TargetModel.GetValue(g.Rows(0), g.Column))
End If
End If
End If
Next
End If
End If
End Sub

Protected Sub FpSpread1_Grouping(ByVal sender As Object, ByVal e As FarPoint.Web.Spread.GroupingEventArgs) Handles FpSpread1.Grouping
Dim c As Integer = e.SortInfo.Index
Dim ss As FarPoint.Web.Spread.FpSpread = sender
Dim dm As FarPoint.Web.Spread.Model.DefaultSheetDataModel
If TypeOf (ss.ActiveSheetView.DataModel) Is FarPoint.Web.Spread.Model.DefaultSheetDataModel Then
dm = ss.ActiveSheetView.DataModel
Else
dm = CType(ss.ActiveSheetView.DataModel, FarPoint.Web.Spread.Model.GroupDataModel).TargetModel
End If

c = dm.GetDataColumnFromModelColumn(c)
If dm.GetDataView().Table.Columns(c).DataType.Equals(GetType(DateTime)) Then
If dm.GetDataView().Table.Columns(c).Caption.IndexOf("Birth") >= 0 Then
e.GroupComparer = New MyGroupComparer(True)
Else
e.GroupComparer = New MyGroupComparer(False)
End If
End If
End Sub
Requirements

Target Platforms: Windows 7, Windows 8, Windows 10, Windows Vista, Windows Server 2003, Windows Server 2008, Windows Server 2012, Windows XP Professional

See Also

Reference

GroupDataModel Class
GroupDataModel Members

 

 


Copyright © GrapeCity, inc. All rights reserved.