I suppose you had better to change your grid layer into a polygon layer. You can use the processing toolbox for this purpose. Using the simplified interface select Geoalgorithms/Vector/Create/Create graticule. The grid type should be Rectangle (polygon) and set up the other parameters.
Add a new unique column to the polygons of the grid layer using the Field calculator from the toolbar of the attribute table.
Intersect your line layer with the grid polygon, again from the processing toolbox: Geoalgorithms/Vector/Overlay/Intersection.
Now you have a new layer where your lines are cut by the grid polygons and the lines got the attributes of the grid, too.
Add a new field to the intersection layer with the length of the line segments, again using the Field calculator.
Finally sum up the length of the lines having the same id (inside the same grid cell) using the processing toolbox Geoalgorithms/Vector/Statistics/Statistics by category.
You find the answer to your question in the "sum" column.
Values in the dialogs should be changed considering your data!