Prepare a grill for medium-high heat. Preheat the oven to 350 degrees F. Grease a 9-by-13-inch baking dish with the butter.
Oil the sliced sweet potatoes and onions with the canola oil and sprinkle with salt and pepper. Grill the sweet potatoes and onions until slightly charred on each side and just halfway cooked. Set aside.
Combine the half-and-half, horseradish, thyme, 2 teaspoons salt and 1 teaspoon pepper in a bowl. Sprinkle one-third of the Gruyere in an even layer over the bottom of the prepared baking dish. Layer one-third of the grilled sweet potatoes and onions on top of the Gruyere. Repeat twice¿one-third of the cheese, one-third of the vegetables¿to create three even cheese-vegetable layers. Pour the half-and-half mixture over the top, cover with foil and bake for 35 to 40 minutes. Uncover and continue baking until the sweet potatoes are tender and the gratin is golden brown, another 15 to 20 minutes. Let rest for 15 minutes before serving.
Recipe courtesy of Guy Fieri