Page 1 of 2

Increasing the editable length of a custom field

PostPosted: Thu Feb 02, 2017 4:07 pm
by indikad
Jiwa 7.0.175

The default field length on a custom field on ( Inventory master for example) is 255.

We have a customer on 6.5.13 that has increased the underlying table column data size and also uses a breakout code to accommodate typing in large number of characters.

the existing 6.5.13 code is below. Can you please let me know a way of achieving this in 7.0.175 ?
simply increasing the field size on the db side will not help according to this post below
viewtopic.php?f=14&t=257&p=756&hilit=custom+field+length#p756

6.5.13 code
Code: Select all
UPDATE IN_CustomSetting SET ScriptFormatCell = '
GridObject.Col = Col
GridObject.Col2 = Col
GridObject.Row = Row
GridObject.Row2 = Row
GridObject.TypeMaxEditLen = 32000
End Sub
' WHERE CellType = 1
GO


Re: Increasing the editable length of a custom field  Topic is solved

PostPosted: Thu Feb 02, 2017 5:36 pm
by Mike.Sheen
Use the FormatCell method in the CustomFieldPlugin class:

Code: Select all
public void FormatCell(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic BusinessLogicHost, JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid GridObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm FormObject, int Col, int Row, JiwaFinancials.Jiwa.JiwaApplication.IJiwaCustomFieldValues HostObject, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomField CustomField, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue CustomFieldValue)
{
   if (CustomField.PluginCustomField.Name == "TestField")
   {
      var cellType = (FarPoint.Win.Spread.CellType.TextCellType)GridObject.ActiveSheet.Cells[Row, Col].CellType;
      cellType.MaxLength = 2000;
   }
}


Sample attached.

Re: Increasing the editable length of a custom field

PostPosted: Thu Feb 02, 2017 9:36 pm
by indikad
Great - thanks for the quick reply. Will try.

Re: Increasing the editable length of a custom field

PostPosted: Fri Feb 03, 2017 5:29 pm
by indikad
I could be doing something wrong.
I used your code ( could not compile your plugin since I am on version 157 and think your would be version/s higher. )
however I used the code highlighted on the forum post but no response.
The underlying "contents" field in in_customsettingvalues takes varchar(-1) - max - anyway

yet the field beeps when I type a string larger than 255 characters.

Re: Increasing the editable length of a custom field

PostPosted: Fri Feb 03, 2017 6:27 pm
by Mike.Sheen
Did you change the field name in this line:

Code: Select all
if (CustomField.PluginCustomField.Name == "TestField")


to match yours?

Re: Increasing the editable length of a custom field

PostPosted: Fri Feb 03, 2017 8:04 pm
by indikad
Yup! sure did. Took it from the SettingName of IN_CustomSetting
it obviously is working for you ! what version are you on?

Re: Increasing the editable length of a custom field

PostPosted: Sat Feb 04, 2017 11:20 am
by Mike.Sheen
indikad wrote:Yup! sure did. Took it from the SettingName of IN_CustomSetting
it obviously is working for you ! what version are you on?


You're going to have to post a plugin demonstrating the issue - I suggest you copy your plugin, remove any irrelevant parts and post it here.

Note that if your custom field is not defined in your plugin, but a different plugin then that could explain the problem - the FormatCell method of the CustomFieldPlugin won't be called for settings in other plugins, just the current one.

Re: Increasing the editable length of a custom field

PostPosted: Mon Feb 06, 2017 10:03 am
by indikad
Note that if your custom field is not defined in your plugin, but a different plugin then that could explain the problem - the FormatCell method of the CustomFieldPlugin won't be called for settings in other plugins, just the current one.


That was it! I had the code in a separate plugin. Moved it to the same plugin that the custom field is on and it works. Thanks.

Re: Increasing the editable length of a custom field

PostPosted: Fri Jul 14, 2017 10:11 am
by Ernst
Hiya Mike,

WHat would the VB version of

if (CustomField.PluginCustomField.Name == "TestField")
{
var cellType = (FarPoint.Win.Spread.CellType.TextCellType)GridObject.ActiveSheet.Cells[Row, Col].CellType;
cellType.MaxLength = 2000;
}

Look like. Thanks

Re: Increasing the editable length of a custom field

PostPosted: Fri Jul 14, 2017 8:49 pm
by Mike.Sheen
Ernst wrote:Hiya Mike,

WHat would the VB version of

if (CustomField.PluginCustomField.Name == "TestField")
{
var cellType = (FarPoint.Win.Spread.CellType.TextCellType)GridObject.ActiveSheet.Cells[Row, Col].CellType;
cellType.MaxLength = 2000;
}

Look like. Thanks


There are really useful and free to use online tools like the Telerik Code Converter which will do this for you.

Putting the above in there and choosing "C# to VB" yields the following:
Code: Select all
If CustomField.PluginCustomField.Name = "TestField" Then
   Dim cellType = DirectCast(GridObject.ActiveSheet.Cells(Row, Col).CellType, FarPoint.Win.Spread.CellType.TextCellType)
   cellType.MaxLength = 2000
End If