class SimpleDataRow
A class representing a single row in a data table, inheriting from ClientValue. It stores cell data as a dictionary and provides methods for property management.
/tf/active/vicechatdev/SPFCsync/venv/lib64/python3.11/site-packages/office365/sharepoint/search/simple_data_row.py
5 - 16
simple
Purpose
SimpleDataRow is designed to represent a row within a data table structure, typically used in Office 365 API interactions. It encapsulates cell data in a dictionary format and provides mechanisms to set properties with OData type parsing. This class serves as a data transfer object for table row operations, allowing structured access to cell values and integration with Office 365 services through the ClientValue base class.
Source Code
class SimpleDataRow(ClientValue):
"""Represents a row in a data table"""
def __init__(self, cells=None):
"""
:param dict cells: The cells in the data table row.
"""
self.Cells = cells
def set_property(self, k, v, persist_changes=True):
self.Cells = ODataType.parse_key_value_collection(v)
return self
Parameters
| Name | Type | Default | Kind |
|---|---|---|---|
bases |
ClientValue | - |
Parameter Details
cells: A dictionary containing the cells in the data table row. Keys represent column identifiers and values represent the cell contents. Can be None during initialization, which creates an empty row. Expected format is a key-value collection compatible with ODataType parsing.
Return Value
The __init__ method returns a new SimpleDataRow instance. The set_property method returns self, enabling method chaining. When instantiated, the object provides access to row data through the Cells attribute.
Class Interface
Methods
__init__(self, cells=None)
Purpose: Initializes a new SimpleDataRow instance with optional cell data
Parameters:
cells: Optional dictionary containing the cells in the data table row. Defaults to None if not provided.
Returns: A new SimpleDataRow instance
set_property(self, k, v, persist_changes=True)
Purpose: Sets a property on the data row, specifically parsing the value as an OData key-value collection and assigning it to Cells
Parameters:
k: The property key (though in current implementation, this parameter is not used and Cells is always updated)v: The value to be parsed and set. Expected to be in a format compatible with ODataType.parse_key_value_collectionpersist_changes: Boolean flag indicating whether changes should be persisted. Defaults to True.
Returns: Returns self to enable method chaining
Attributes
| Name | Type | Description | Scope |
|---|---|---|---|
Cells |
dict or None | Stores the cells in the data table row as a dictionary where keys are column identifiers and values are cell contents. Can be None if no cells have been set. | instance |
Dependencies
office365.runtime.client_valueoffice365.runtime.odata.type
Required Imports
from office365.runtime.client_value import ClientValue
from office365.runtime.odata.type import ODataType
Usage Example
# Create an empty data row
row = SimpleDataRow()
# Create a data row with initial cells
cells_data = {'Column1': 'Value1', 'Column2': 'Value2', 'Column3': 123}
row = SimpleDataRow(cells=cells_data)
# Access cell data
print(row.Cells)
# Set property with OData parsing (method chaining supported)
row.set_property('Cells', {'NewColumn': 'NewValue'}, persist_changes=True)
# Chain multiple operations
row.set_property('Cells', {'A': '1'}).set_property('Cells', {'B': '2'})
Best Practices
- Initialize with a dictionary for cells parameter to ensure proper data structure
- Use set_property method when updating cells to ensure proper OData type parsing
- The set_property method returns self, allowing for method chaining when multiple updates are needed
- The persist_changes parameter in set_property should be set to True when changes need to be persisted to the backend
- Cells attribute is public and can be accessed directly, but modifications should preferably go through set_property for consistency
- This class is typically used as part of a larger Office 365 data table structure, not in isolation
- Ensure cells dictionary keys match the expected column structure of the target data table
Similar Components
AI-powered semantic similarity - components with related functionality:
-
class SimpleDataTable 71.9% similar
-
class ClientValue 59.5% similar
-
class ResourceData 53.4% similar
-
class PageDetails 52.5% similar
-
class Visualization 52.0% similar