Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataGrid: add ToODataString API to the ReadData event arguments #5582

Merged
merged 6 commits into from
Jun 27, 2024

Conversation

David-Moreira
Copy link
Contributor

No description provided.

@David-Moreira David-Moreira linked an issue Jun 20, 2024 that may be closed by this pull request
@David-Moreira
Copy link
Contributor Author

@stsrki Any customer that would be willing to take this for a spin using 1.6 preview?

@stsrki stsrki changed the title Datagrid add toodatastring api to the readdata DataGrid: add ToODateString API to the ReadData event arguments Jun 21, 2024
@stsrki
Copy link
Collaborator

stsrki commented Jun 21, 2024

@stsrki Any customer that would be willing to take this for a spin using 1.6 preview?

I have someone in mind.

@David-Moreira David-Moreira changed the title DataGrid: add ToODateString API to the ReadData event arguments DataGrid: add ToODataString API to the ReadData event arguments Jun 21, 2024
Copy link

@mrpmorris mrpmorris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Edit the page at tests/datagrid
  2. In OnReadData add string oDataQuery = e.ToODataString( "https://ibm.com" );
  3. Run the app, visit the page
  4. Enter gmail in the email filter

Expected: oDataQuery should have a $filter entry
Actual: It doesn't

@David-Moreira
Copy link
Contributor Author

Fixed @mrpmorris Would you be so kind to retest?

@stsrki The problem here, was that the column filter method is null on read data, which is somewhat correct since these columns have no FilterMethod specifically defined.
However, I think it should be fine, that if it's not defined at column level, we propagate the current DataGrid filter method as I've just changed. Please let me know your thoughts.

@stsrki
Copy link
Collaborator

stsrki commented Jun 26, 2024

@stsrki The problem here, was that the column filter method is null on read data, which is somewhat correct since these columns have no FilterMethod specifically defined.
However, I think it should be fine, that if it's not defined at column level, we propagate the current DataGrid filter method as I've just changed. Please let me know your thoughts.

Yeah, I think that should be fine.

@stsrki
Copy link
Collaborator

stsrki commented Jun 27, 2024

@mrpmorris mentioned a way to test the filter quickly.

...

public Task<List<Employee>> FilterData( IEnumerable<DataGridColumnInfo> dataGridColumns, string oDataQuery ) <-- Added string parameter
...

        var values =
            new Uri( oDataQuery )
            .Query
            .ToKeyValuePairs()
            .ToDictionary( x => x.Key, x => HttpUtility.UrlDecode( (string)x.Value ) );

        var source = filteredData.AsQueryable().OData();
        if (values.TryGetValue("$filter", out string f))
            source = source.Filter( (string)f );


        //foreach ( var column in dataGridColumns.Where( x => !string.IsNullOrWhiteSpace( x.SearchValue?.ToString() ) ) )
        //{
        //    var valueGetter = FunctionCompiler.CreateValueGetter<Employee>( column.Field );
        //    filteredData = filteredData.Where( x => valueGetter( x )?.ToString().IndexOf( column.SearchValue.ToString(), StringComparison.OrdinalIgnoreCase ) >= 0 ).ToList();
        //}
        return Task.FromResult( source.ToList() );
    }

and

<PackageReference Include="Community.OData.Linq" Version="2.1.24-rc" />

Copy link
Collaborator

@stsrki stsrki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@David-Moreira If you think you will not need anything else I will merge it.

@David-Moreira
Copy link
Contributor Author

LGTM.

@David-Moreira If you think you will not need anything else I will merge it.

Yep, fine by me.

@stsrki stsrki merged commit 89e0e63 into master Jun 27, 2024
2 checks passed
@stsrki stsrki deleted the 5550-datagrid-add-toodatastring-api-to-the-readdata branch June 27, 2024 14:53
@github-actions github-actions bot locked and limited conversation to collaborators Jun 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataGrid: add ToODataString API to the ReadData
3 participants