Syncfusion mvc grid control filtering on hyperlink column - syncfusion

I have just been trying out syncfusion controls for mvc and have come across bit of a hurdle. My problem is that when i use a hyperlink in ej grid column using column template feature the filters just don't work for that column. My current UI is designed that way that i need to render a column value as clickable link and i also need to allow filtering on the basis of value in that column.

To perform actions like filtering, sorting, grouping Fields must be enabled to column. Based on the column value above actions will be performed. To perform filtering in template column,define the Field property to template column.
Refer the below code example
#(Html.EJ().Grid<EmployeeView>("ColumnTemplate")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowPaging()
.ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.ExcelExport);
items.AddTool(ToolBarItems.WordExport);
items.AddTool(ToolBarItems.PdfExport);
}))
.Columns(col =>
{
col.HeaderText("First Name").Field(“FirstName”).Template("#columnTemplate").TextAlign(TextAlign.Center).Width(80).Add();
col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(100).Add();
col.Field("LastName").HeaderText("Last Name").Width(100).Add();
col.Field("BirthDate").HeaderText("Birth Date").TextAlign(TextAlign.Right).Width(100).Format("{0:MM/dd/yyyy}").Add();
col.Field("Country").Width(100).HeaderText("Country").Add();
})
)
Please get back to us if you have further queries.

Related

How to Ignore selected rows when filtering using floating filters in ag-grid?

I'm currently working on a project that uses ag-grid in Angular.
We have a table that displays some sort of data and it's possible to filter this table using some textbox floating filters above the table for every column.
Every row has a checkmark in the beginning that can be used to select this row.
The goal is to figure out a way to not filter out the rows that have been selected by the user. The rest of the rows should get filtered as normal.
Is there an easy way to implement this?
I've been looking trough the documentation and it seems like I will have to write a custom filter component, but I'm not sure where to start. Do filters even have the capability to check if a row is selected or not?
So I figured out an easy way. I created a new simple class:
export class IgnoreSelectionFilter extends TextFilter {
doesFilterPass(params: IDoesFilterPassParams): boolean {
if (params.node.isSelected()) return true;
else return super.doesFilterPass(params);
}
}
I use this class as the "filter" component for every column where this functionality is required. This new class behaves exactly like agTextColumnFilter, but first it will verify if the node is selected or not and ignore it if it's selected.

Filtering a datasource using multi select wild character

Does anyone know if there is a wildcard character in AppMaker that can be used for all possible values for a field in a query?
I currently have a datasource that is being filtered based on the status using a multi-select widget. What I would like to accomplish is when all values have been de-selected I want to load all the records of that datasource without clearing the entire query in case other filters have been applied. I have it working in-a-sense that I have to explicitly construct my query as such:
widget.datasource.query.filters.Status._in = ['Status Value 1','Status Value 2','Status Value 3']
My current solution is loading the correct data when a value is selected and it correctly shows the union of the query as the values are modified. However, it selects all of the values in my multi-select; which I know is how it is supposed to work.
I tried using widget.datasource.query.filters.Status._contains = ''; and changing the assignment value to no avail. I even tried the opposite approach using _notContains
The intended outcome is to have a filtering dashboard appear much like any website where when no filtering is selected all records are displayed. I was hoping to find a wildcard character that would load all of the records. Just trying to find a way to mimic other website filters with all records when none are selected.
Thanks for the time!
So the easiest solution here is to set up your Multiselect as follows:
Options binding:
#models.YourModel.fields.Status.possibleValues
or if you don't have the possible Status values in your model then set your options binding to:
['Status Value 1','Status Value 2','Status Value 3']
Values binding:
#datasource.query.filters.Status._in
Now anytime you select any choices in the multiselect, the query will only include records that include the selected choices. And if you deselect all choices the query will ignore that filter or treat it as an empty array of values, therefore returning all records unless you applied other filters.

Hide column name in personalization dialog box based on condition

I have p13n dialog box in a table, where I am displaying 2 columns coming from the backend.
Now, I want to implement condition in column 2. For example,
if(mainCondition === true)
{
display column2;
}
else
{
hide columns2;
}
The issue here is, these column names are coming from CDS view & with entity set.
I can, of course, hide them completely using the setIgnoreFromPersonalisation method, however, I don't know how can I implement condition on these field's visibility property.
Thanks.
Since the two columns are coming from the backend, you can add Filter to the model to filter out the ones to be hidden.

SqlDataSource filter on conditional dropdownlist values

i have 3 dropdownlists that i need to filter my datasource at runtime.
Each of the dropdownlists must be combined with the other two BUT they also have a 'special' value of "ALL". in this case i want to disable filtering on the specific filed and show all values.
Does this come with some out of the box functionality from asp.net or i have to build the string every time ?
After searching in many places i finally found out that there is NOT an out of the box functionality of asp.net to dynamically build WHERE clauses based on the values of every control that i want to participate in filtering.
I ended up with custom coding on the gridview selectedindexchanged event that builds the selectcommand text and binds the gridview again.
works fine!

Telerik MVC: Generic Grid

I am wondering if I could design a generic way to design a Telerik MVC Grid.
Example:
Model is a List of FieldDescriptor. A FieldDescriptor has a name, a value and a type.
Thus I want to show the colums of the Grid according to the data in the model - depending on which fields come and what their type is.
But the Telerik MVC Grid only knows how to make a column, if you explicitly refer a model property.
I found a blog that explained what I think you are asking. How to display a dynamic datatable when you don't know what the columns are until run time.
You can loop through the columns in model to build the grid, then use ajax to go get the data.
Here the link www.alexrogan.com
Here is how you can loop through the column values of a datatable to create the grid columns.
.Columns(columns =>
{
foreach (System.Data.DataColumn column in Model.Columns)
{
columns.Bound(column.DataType, column.ColumnName);
}
})