Why MappingName for sfgrid:GridTemplateColumn

OK , why is the MappingName required for the GridTemplateColumn?  A template is taking info from the BindingContext and binding them to controls.  Just spent a couple of hours trying to find out why I was getting a 

" value cannot be null parameter name key" error.  Looking around I saw a sample with the NEVER USED MappingName set.  So I set it to useless info and it works.

Any idea what is happening or more useful why it is happenign


2 Replies

LS Lloyd Sheen January 28, 2022 07:40 PM UTC

Ok to put some perspective on this I did the following:

  1.  Changed MappingName to an existing property name.  This made no difference 
  2. Changed MappingName to a non-existing property name.  This made no difference
  3. Removed MappingName from GridTemplateColumn.  This caused the error.

Thus you should be able to see that there is a non used property on the GridTemplateColumn (MappingName) that has no use but if you don't provide something it causes an error and the error 


SV Suja Venkatesan Syncfusion Team January 31, 2022 02:48 PM UTC

Hi Lloyd, 

Regarding query “Need of Mapping Name for GridTemplateColumn” 
  • By default, the data operations (sorting and grouping) will be performed based on MappingName property. So we need to assign the Mapping name for the GridTemplate Column.
  • If we assign a non-existing property name to MappingName, columns will be generated without error, but data operations will not be reflected in that column.
  • If the MappingName property for the GridTemplatecolumn is not assigned, a “System.InvalidOperationexception” with message “MappingName is necessary for defining the column” gets thrown. Could you please confirm if you are experiencing the same exception or any other error?. If you encounter the same exception, please set the mapping name to GridTemplateColumn, otherwise share the error details with codes related to SfDataGrid. It will be more helpful for us to provide the timely solution.

Regards, 
Suja 



Loader.
Up arrow icon