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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

List grouping by spfx computed column does not work - always group as not set #9668

Open
1 of 9 tasks
CarlVerret opened this issue May 3, 2024 · 5 comments
Open
1 of 9 tasks

Comments

@CarlVerret
Copy link

What type of issue is this?

Question

What SharePoint development model, framework, SDK or API is this about?

馃挜 SharePoint Framework

Target SharePoint environment

SharePoint Online

What browser(s) / client(s) have you tested

  • 馃挜 Internet Explorer
  • 馃挜 Microsoft Edge
  • 馃挜 Google Chrome
  • 馃挜 FireFox
  • 馃挜 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

  • browser version
  • SPFx version
  • Node.js version
  • etc

Issue description

Having a custom spfx computed column in a list (wich displays true or false depending if two other fields are equal), when we select "Group by this column", the only group that is displayed is "Not set" (Non appliqu茅 in french)

image

@mkm17
Copy link

mkm17 commented May 11, 2024

Hi @CarlVerret, could you provide information about the calculated column and view grouping setting? I have checked it on my side and I can see the correct grouping label for a calculated column.

image

@CarlVerret
Copy link
Author

CarlVerret commented May 13, 2024

Hi Micha艂,

In fact I had to use a custom spfx field to compare if, under some circumstances two dates were equal or not, returning a simple Yes or No text value.

public onRenderCell(event: IFieldCustomizerCellEventParameters): void {

const monItemEnCours = event.listItem;

if ( ... ) // ... under some condition, set value to blank
{
event.domElement.innerText = "";
}
else
{

  const date_approb:Date =  monItemEnCours.getValueByName("approved date");
  const date_modif:Date = monItemEnCours.getValueByName("Modified");
  event.domElement.innerText =  date_modif <=date_approb  ? "Yes" : "No";
  
}

}

The display works perfectly in list's columns. But grouping by this column result in only "Non affect茅" (not set in french) values. Even if the cell render produces values.

@mkm17
Copy link

mkm17 commented May 13, 2024

@CarlVerret Unfortunately, it will not work like this. The SPFx field customizer does not change the value of a field; it just overrides the rendering of the column field. Maybe you can try using a calculated column formula instead. Try comparing both dates with conditional formulas:
https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/bb862071(v=office.14)#conditional-formulas

If there are additional conditions, such as comparing both dates when the status of the items is 'Approved,' then simply add a nested IF statement.

@CarlVerret
Copy link
Author

The main reason we opted for a custom field is that there's no easy way to compare two dates natively with calculated columns. If there's one, we could figure it out ! This is something that is asked a lot about in many forums.

@mkm17
Copy link

mkm17 commented May 13, 2024

I've reviewed the calculated column formula where I check the value of the Status column and compare the Modified date with my Approval DateTime column.

Of course, use ';' or ',' depending on the language on the site.

=IF(Status="Choice 2";IF(((Modified-[Approval DateTime])<0);"OK";"Not OK");"")

The effect is like this.

image

Of course, your case may be more complicated, and as you mentioned then other solutions may need to be considered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants